Notepad Calculator(using WIN32API hooking)

Overview

Developed a Notepad Calculator by hooking into the WIN32 API to transform Notepad into a functional calculator. This project demonstrates the ability to intercept and modify API calls to extend the capabilities of a basic text editor.

Motivation

One of my hobbies is reverse engineering, where I dive deep into the inner workings of software to understand, modify, or enhance its functionality. Recently, I found myself getting frustrated with the basic calculator that comes pre-installed on most operating systems. While it’s great for quick calculations, it becomes cumbersome when trying to input slightly more complex expressions or when the window size doesn’t provide enough space to view the full equation.

I began to wonder: what if there was a way to combine the simplicity of a text editor with the functionality of a calculator? That way, I could freely type out calculations in a larger, more flexible space while retaining the ability to perform real-time calculations.

That’s when the idea struck me. I decided to use one of the simplest and most universally available programs—Notepad—and turn it into a functional calculator using my reverse engineering skills. By leveraging API Hooking techniques, I could intercept and modify the behavior of Notepad to allow it to calculate expressions directly within the text editor. This would let me type out equations in a familiar, spacious environment, with instant feedback on the results.

The Challenge

The task wasn’t as simple as it first appeared. Notepad, while basic, is not designed to handle complex functionalities like parsing mathematical expressions or returning real-time calculation results. Moreover, modifying an existing program without altering its original code requires precise and non-intrusive techniques, making API Hooking the perfect solution.

I chose to hook into the file-saving process of Notepad. By doing so, I could intercept the moment when the user saves the file, analyze the text for any mathematical expressions, perform the necessary calculations, and then save the result directly within the file. This approach allowed me to maintain the integrity of Notepad’s user interface while adding the functionality I needed.

The Implementation

I began by analyzing the system calls that Notepad makes, particularly those related to file operations. By hooking into the save function, I could intercept the text being saved and check if it represented a valid mathematical expression.

Whenever I typed an equation and saved the file, my hooked function would parse the expression, perform the necessary calculations, and then write the result directly into the file. This means that after saving, the file would not only contain the original equation but also the computed result right next to it. The beauty of this approach is that it doesn’t alter the Notepad executable or require any additional interfaces—everything happens seamlessly within the existing Notepad framework.

The Result

The result is a tool that combines the best of both worlds: the flexibility and simplicity of Notepad, with the added functionality of a basic calculator. I can now type out equations in full, see the entire context of what I’m calculating, and get instant results simply by saving the file, without having to switch between programs or strain my eyes trying to fit everything into a tiny calculator window.

This project not only solved a practical problem but also provided a perfect opportunity to apply my reverse engineering skills in a fun and useful way. By using API Hooking, specifically during the file-saving process, I was able to extend the functionality of a simple program like Notepad, demonstrating how powerful and versatile reverse engineering can be when applied creatively.

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top