DEV Community

Yuil Tripathee
Yuil Tripathee

Posted on

Reverse engineering C code with Cflow - GNU project (to trace back calling)

Install the program in Linux (Ubuntu used for this test case) using the below command:

apt search cflow
sudo apt install cflow
Enter fullscreen mode Exit fullscreen mode

After this, go to the specific project folder. To run the analysis, you can run the following command.

cflow --verbose --tree main.c
Enter fullscreen mode Exit fullscreen mode

In this example, we can analyze main.c. Changing the file name allows us to check other files as well. The output is printed on ASCII tree format with quality details. Now, you can use this information to draw on the software design applications such as PlantUML or StarUML manually if you would like to have a graphical presentation of your reverse analyzed C code.

Here's the example printout:

+-main() <int main (int argc, char *argv[]) at main.c:26>
  +-printf()
  +-serial_open()
  +-WitInit()
  +-WitRegisterCallBack()
  +-SensorDataUpdata() <void SensorDataUpdata (uint32_t uiReg, uint32_t uiRegNum) at main.c:100>
  +-AutoScanSensor() <void AutoScanSensor (char *dev) at main.c:142>
  | +-serial_close()
  | +-serial_open()
  | +-WitReadReg()
  | +-Delayms() <void Delayms (uint16_t ucMs) at main.c:136>
  | | \-usleep()
  | +-serial_read_data()
  | +-WitSerialDataIn()
  | \-printf()
  +-serial_read_data()
  +-WitSerialDataIn()
  +-Delayms() <void Delayms (uint16_t ucMs) at main.c:136>
  | \-usleep()
  \-serial_close()
Enter fullscreen mode Exit fullscreen mode

The source is from Linux C SDK for Witmotion IMU sensor. Here's the link for documentation: https://support-73.gitbook.io/witmotion-sdk/wit-standard-protocol/

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay