serge1 / COFFI

A header-only C++ library for accessing files in COFF binary format. (Including Windows PE/PE+ formats)
MIT License
184 stars 28 forks source link

Write COFF files #4

Closed belissent closed 4 years ago

belissent commented 4 years ago

I am thinking of extending COFFI in order to be able to create, modify and write COFF files. I already have a small prototype partially working. What do you think of this idea?

serge1 commented 4 years ago

Hi Pierre, I started this project for the purpose of reading COFF files only. (That is why the name - as an opposite to ELFIO ;-). Taking into the account the diversity of the COFF formats for different architectures, switching to ELF format nowadays, I didn't put much effort for extending COFFI. In case you see a value for developing the project further, I'll accept any changes from you automatically

belissent commented 4 years ago

I pushed the prototype in a separate branch coffio. If you have time, you can have a look at it, and tell me if I should make a pull request to the master.

serge1 commented 4 years ago

Hi, what you did is just amazing! I have committed the changes from coffio branch to master. Special thanks for following coding conventions. Do you think it will be possible to extend 'answer.exe' example to print something?

serge1 commented 4 years ago

Additional question - would it be possible to eliminate (or, at least, reduce) the output of the test program?

belissent commented 4 years ago

Do you think it will be possible to extend 'answer.exe' example to print something?

I don't know how to do this (in the writer example). Anything requires the standard libraries+startup code. Even the management of the environment variables seems to require those. In the EXE generated by the example, the return value is not passed as %ERRORLEVEL% to the calling shell. I suspect that it is due to the environment not being managed in the EXE.

belissent commented 4 years ago

Do you think it will be possible to extend 'answer.exe' example to print something?

It will try something, based on http://www.phreedom.org/research/tinype/

serge1 commented 4 years ago

Initially I thought about BIOS interrupts, but, most likely, it will not work under the Windows OS.

serge1 commented 4 years ago

So, in case it requires an effort, please don't bother

belissent commented 4 years ago

Mission accomplished: #5 If you agree with the modifications, would it be possible to draft a new release ?

serge1 commented 4 years ago

Done. Release_1.0 tagged

serge1 commented 4 years ago

Hi Pierre,

serge1 commented 4 years ago

I reached my Windows machine and recognized that you succeeded to implement PE Hello World program by using COFFI library. It is just amazing! Thanks a lot!

belissent commented 4 years ago

Thanks. The project would require a little bit of documentation: Do you have any preference/advice regarding the documentation generator? What do you think of Read the Docs?

serge1 commented 4 years ago

Indeed, in the current state (thanks to you), the project deserves documentation. I have no preferences and have no experience with "Read the Docs". Does it support C++ code? From what I saw, it is Python oriented. Alternatively, we may create documentation similar to ELFIO's user manual. It will require a bit of manual work though. If an automatic way exists, it will be preferable.

P.S. I am using your MASM code as a snippet for "Hello World" program in VSCode plugin called "Multi Language Hello World"

belissent commented 4 years ago

A prototype running on my GitHub fork is starting to work: https://coffi.readthedocs.io/ Many things don't work properly (code snippets, some images, documentation is far from complete, inheritance diagram is broken, missing images and PDF files, etc.).

This gives an rough idea of what could be done, and the impact on the source code that contains the documentation.

Doxygen is in my opinion much more complete than sphinx for the C++ projects.

serge1 commented 4 years ago

The documentation looks much better that I could expect. I think this alternative to Doxygen is good enough.

serge1 commented 4 years ago

In case of future development of this project, please add yourself as the author and the owner of the project