c# - Open a *.COM file using stream -
just found myself in need of opening *.com files in c# application. *.com files generated fasm, assemly code one:
org 100h
jmp start
msg: db "hi", 0dh,0ah, 24h
start: mov dx, msg
mov ah, 09h int 21h mov ah, 0 int 16hret
when opened textprocessors sublime, it's represented code represented this:
eb05 4869 0d0a 24ba 0201 b409 cd21 b400
cd16 c3
i tried open file in application code one
string comtext = file.readalltext(filename,encoding); byte[] info = new utf8encoding(true).getbytes(comtext); when checked messagebox.show(info[i].tostring("x2")); says, first byte ef, 2nd bf (splitting eb in halfs), adding 1 additional byte on 3rd place (bd). after - parsed planned. 4th:05, 5th:48 etc. do wrong , there way fix without workaround (which 1 unclear me @ stage, because don't know if have same behavior or dont)
you need open file binary stream, not text steam. text getting encoded unicode surrogates.
use file.openread byte array. can use file.readallbytes don't recommend since large file cause outofmemoryexception.
Comments
Post a Comment