first .c file is embedded coding written in KEIL IDE from which hex file is generated. Now I want to convert the hex file back to .c file. Is it possible? If YES, HOW?
Can we convert a hex file back to .c file?
8.5k Views Asked by Reddy Rohit AtThere are 2 best solutions below
Clifford
On
Just like you cannot convert a cake into its ingredients, you cannot convert machine code to the source code that created it.
Much of what appears in source code is for the benefit of the human or to facilitate the compile/link process and is discarded in the hex file.
Attempts at "decompilers" do exist, but are academic or experimental in nature, or work with code generated by specific compilers for specific and would struggle with code that has been generated with compiler optimisation. Moreover such tools work with object files (.axf in Keil ARM) which may retain some metadata on which the decompiler can work, such as entry point or possibly symbol or debug information. A hex file is simply a binary image encoding and has all that metadata stripped - it is just machine code instructions and program data.
Related Questions in EMBEDDED
- MSP430F5529 on the MSPEXP430F5529LP: UART is not actually transmitting despite seemingly correct setup. What is wrong?
- A FPGA Project Proposal where I can use both PS and PL
- Program doesn't run after DFU
- Sending struct through queue
- How to generate a VPI warpmap for polynomial distortion correction?
- How to present this example concept in UML: Using 2 LCD displays in C/C++
- CLion: Debug via St-Link
- Portenta H7 Baremetal Development and a Little Guidance on Embedded System Learning Roadmap
- STM32 RTC3 Mixed Mode: Writing TR resets SSR
- Unable to read value from gpio set as input
- Mbed TLS: in-place en-/decryption for OAEP doesn't seem to work
- Shared variable read from low priority thread in preemptive scheduling
- Own Pattern / framework for interfacing with components in C
- Performance Difference Between Global Variable and Local Variable in Embedded Systems
- Comparing analog signal from Electret mic with samples
Related Questions in HEX
- From Buffer("string", "hex) to string JS
- Dart: how to convert Hex String to Ascii string
- How to convert n most significant bits in a hexadecimal byte string in Python 3
- keil debugging mode doesn't work properly
- How to save Hex value characters from char array elements to a char array, TCHAR, LPCTSTR, and CString?
- hex representation for integers in Golang
- Convet byte[] in ASCII
- Hexadecimal radix to sort a list of 4-byte integers
- python to_bytes() to return an even number of digits
- SASS invalid syntax hexadecimal color on 8 degit with rails?
- Convert binary to hexadecimal using MASM32
- Is there anything wrong with checking two hex values using == in C?
- Interpreting Bluetooth BLE Data from Flutter App: Understanding Systolic Pressure Values
- C++ uint16_t to hex
- Edit the file and replace the Hex value with Bash script
Related Questions in EMBEDDED-LINUX
- Touch calibration error when using Avalonia UI with Raspberry PI 4 (lite) DRM Mode
- Can't ping to 8.8.8.8 and google.com in beaglebone black
- How to extract the .img file into normal kernel source file in the linux?
- Using C++ libgpiod to calculate interval and speed between events
- yocto bitbake 'python3 setup.py bdist_wheel ' execution failed
- How to reduce cached memory used by Linux kernel on embedded linux platform
- Unable to parse input tree, possibly due to dash
- How to add a button handler to GPIO pin through a push button
- Linux of_platform_depopulate() does not remove drivers
- Filling a sk_buff with content of recieved frame
- How to reduce reserved memory allocated by Linux kernel during boot time
- embedded linux buildroot how to work with axi-gpio?
- How do I know when the dsa_loop and dsa_loop_bdinfo linux kernel modules are working?
- buildroot for zedboard, how to enable axi-gpio in device tree?
- Driver is not loading when there 2 or more source files
Related Questions in HEXDUMP
- How to restore damaged (mp3?) file
- Powershell Reg Multi_SZ into String ( Export / Import Scenario )
- How to perform diffsception (diffing intermediary diff outputs together to filter out irrelevant changes)
- Nasm: Problem in print Hex info from BMP image
- When hexdump is used with a -x option, are the bytes to the right of each group low addresses?
- Formatting powershell Get-Content byte code from file
- How to fix hyphen for sed using hd -c
- How to Read 2 byte data from the binary file using the linux command for e=windows machine?
- Information in binascii.hexlify() Doesn't Slice Correctly?
- How can I get a character coordinates by parsing the bytes of a file?
- writing a single sector into a dump binary file using vba
- Recreate hexdump -C format as -e argument
- Python TypeError: cannot use a string pattern on a bytes-like object
- How do I set Ghidra to display static addresses in the listing view?
- How to open a file in HEX regardless of its extension and size?
Related Questions in HEX-EDITORS
- Is there a way to define template with optional structure for hex editor?
- Hex Editor - Seems that Peplink .report files have changed again, can they still be opened?
- HxD Hex Editor Dark Theme
- Corrupted value when passed as input to a constructor
- Copy file using hexdump and hexedit
- ChromeDriver malfunctions when I change it (Selenium, Python)
- I'm losing binary data when using fseek in c
- How can I write hexadecimal data in the file so that additional data is not written (like hexeditors)?
- How are char arrays / strings stored in binary files?
- Hex Editor - Peplink .diag files changed - Can they still be opened?
- Manually patching an elf binary - adjusting symbols / versions names
- How to insert RAW Hex data from a text file?
- 010 Editor template: convert a int to wchar_t
- Structured binary data compiler/decompiler?
- Producing many different hashes of a jpg file with minimal change to picture
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Sadly, no this is not possible.
You can disassemble the code into an object listing using
objdump -Dbut you would need some knowledge of the target system even to identify which parts are code and data. If you have this and can read assembly code then you can find out what some specific part of the code does, but this is a very time-consuming process.To convert fully back to a high level language like C you would need a decompiler. Without details of the specific target that you are using then the best thing to advise about this is that you just google search for "decompiler".
The problem is that although the output of the decompiler is valid C, it will probably look nothing like the original input. A hex file does not contain any information about the names of functions or variables, so every object will just have an automatically generated name that doesn't mean very much.