ZephrFish / C-from-Scratch

A roadmap to learn C from Scratch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C from Scratch

In March 2023, I decided to learn C from scratch. Throughout this journey, I used various resources—some were beneficial, while others were not as much. I have compiled a list of the most helpful resources into a roadmap for anyone who wishes to do the same. It should save you some time sifting through mediocre materials.

Once I felt comfortable with C, I went lower—specifically, x86-64 Assembly and x86-64 OS Internals. I have included the resources I used for these topics as well.

Note, this is not a 'learn C in 10 hours' roadmap. A more realistic estimate would be to add a couple more zeros.

C

ZF addition Learn C

If you're anything like me, interactive learning is best suited for how you pick stuff up, aka hands-on keyboard learning. The site is an interactive walkthrough similar to the older days of code academy.

If you have not had any formal education in computer science, I recommend to start with the 2023 version of CS50 (that's the one I completed, so I can only recommend that). Start at week 0 and continue through to week 6. For each week, make sure to watch the lecture, section, shorts, and complete the problem sets.

Next, move on to h0mbre’s project-based C course. After CS50, you should be able to breeze through this course relatively quickly. I recommend this because it is an excellent opportunity to practice and apply your skills without the support structures provided in CS50.

You can find my solutions to the assignments here.

There may be some instances where you need to review or deepen your understanding of certain topics. Below are a few areas where I needed further clarification:

Pointers

Input Sanitization

If you know of any other helpful resources in this area, please drop me a message on X.

Data Structures

Comprehensive Guides

This includes a primer on C along with lots of other useful information related to the language and computer science.

I don’t believe there is one particularly special textbook for learning C. However, I often found the explanations in this book to be very clear and helpful. If you encounter a concept not covered in the other resources, such as unions or enumerations, this book is an excellent reference.

Individual Project

By this point, you should be prepared to start your own project. Personally, I found it hard to choose one, as I was constantly searching for the perfect 'beginner-friendly' project which aligned with my interests. However, I realised that this approach isn’t beneficial at all. A calculator, hash table, or tic-tac-toe project will just bore you. Pursue a project that genuinely interests you, regardless of its difficulty. You will likely face some setbacks, but the valuable lessons you learn through these experiences are what truly matter.

If you’re interested in malware development, head over to Vx Underground and read some of their white papers and malware source code.

I decided to develop a kernel driver and a rootkit. If you intend to delve deeper into x86-64 OS Internals, I would highly recommend this route as Windows kernel development and x86-64 OS Internals are closely interconnected. However, you should first learn x86-64 Assembly.

x86-64 Assembly

OpenSecurityTraining2’s courses are absolutely incredible and include tons of practical labs that help cement concepts. You will not be bored with Xeno.

I found the first and second chapters of Computer Systems: A Programmer's Perspective complements Arch1001 nicely. Chapter 1 provides a excellent overview of computer organisation, and Chapter 2 helps to thoroughly understand bits, logic, and C data types. However, if money is an issue, use CS107’s Computer Organization and Systems reader (mentioned earlier) as it covers similar topics and is free.

I have posted a number of writeups to Arch1001 on my GitHub which you may find helpful.

x86-64 OS Internals

So, before starting Architecture 2001, I strongly recommend reading at least the first four chapters of Windows Kernel Programming, Second Edition. This will lay a solid foundation for the course. I also advise thoroughly reading Chapter 1 of Windows Internals, Part 1. The other chapters should be used more as a reference if you find yourself stuck.

I have also published a blog post on Interrupt Handling and Stack Switching in x86-64 Architecture, inspired by some difficulties I faced in a lab from Arch2001.

I will continue to update this list as I encounter more helpful resources.

About

A roadmap to learn C from Scratch