Author image

Console on a Windows GUI Application

Provision Windows C++ GUI applications with a fully featured & functional console window that you can use for logging or whatever other purpose you deem would prove useful.

I used Windows 8.1 x86_64, Visual Studio 2017 & C++17 to build the project.


Github repository link.

Author image

Code Injection

Code injection is a technique where you can insert code into a process and then reroute its execution to traverse through your injected custom code segment.

Working from a debugger eg. OllyDbg, we can search for “code caves”, ie. sequences of nop (or "DB 00" in Olly) instructions that are large enough to "fit" our custom code.

Alternatively we can also allocate more memory in the target process to store the code. This is what we will do in this case.

One of the best ways to inject code is via dlls, because they are meant to be loaded by multiple processes at runtime.

Compulsory ingredients:

  1. injector process - DLLInjector project - the process that will "inject" the code
  2. the process to inject - ProcessToInject project - the process...

Author image

DLL & Linking Tutorial

A DLL (.dll) or dynamic link library (or shared library for *nix connoisseurs - .so for Linux and .dylib for MAC) is a library containing code and data that can be used by multiple programs at the same time. Dlls reduce the size of the executable and the memory usage of the operating system in general, since all applications just need to refer to a single place in memory to use a function in the library (instead of each application having its own copy of it).

Dlls help with separating concerns and reasoning about your code. It also serves for separate compilation, if we change the dll then we need to compile only the dll; the application code remains unaffected and unaware of the change (in this context it resembles the PIMPL idiom). It's worth noting that dll's are a little slower compared to static libraries (which are included in the executable/process), but that speed...

Author image

Process Hacking (COD4) Tutorial

Generic Windows process hacking application. This time the victim being Call of Duty 4 (the original).

What do we mean by hacking? Hacking is gaining access to a system in a manner that was not intended by its developer.

Here we do something really really simple and easy. We will change some on screen visual values in our program.

A. We find the process' HANDLE. There are 2 ways to do this.

I. By getting the window Handle (HWND)

  1. HWND windowHandle = FindWindowW( nullptr, processName ) to get the window handle
  2. GetWindowThreadProcessId( windowHandle, &pid ) to get the pid
  3. and finally OpenProcess( PROCESS_ALL_ACCESS, false, *pid ); to get the process Handle

This is the method I use in this example.

II. By taking a...

Author image

Hooking Tutorial

Here you will learn about this ancient miracle cure called Hooking. Our ancestors used hooking to catch fish! No just kidding, lets get to it..

Before we head straight into it, I'll provide a little introduction to the Portable Executable (PE) and explain its various memory sections. Don't skip it; its understanding is crucial to get to the next part.

The Portable Executable (PE) format is a file format for executables, object code, DLLs, FON Font files, and others used in 32-bit and 64-bit versions of Windows operating systems. It is a data structure format that encapsulates the information necessary for the Windows OS loader to manage the wrapped executable code. This includes dynamic library references for linking, API export and import tables, resource management data and thread-local storage (TLS) data.

The Extensible Firmware Interface (EFI) specification states that PE is the standard executable format in EFI environments. On NT...

Author image

Morse Code Converter

A Morse Code Converter converts a given input string to Morse Code based sounds. Morse code is a telecommunication method used to encode text characters as sequences of different signal durations called dots and dashes.

Working algorithm is straightforward to program:

  1. prompts the user to enter a text string
  2. it decodes the text string to individual characters and maps them to the right combination of the 2 morse code characters according to the International Morse Code table below.
  3. it uses the WinApi Beep function (in 1kHz arrangement) to play the . or the - sound. Traditionally the dash has a longer sound duration so I use 240ms for a dash's playback and 80ms for a dot' playback (3x).

I know Beep is considered old, but is still very much functional and used. I'm a staunch supporter of "If it ain't broke don't fix it" ideology. In Windows 7...

Author image

WinAPI KeyLogger

A basic WinApi keylogger that records keystrokes and writes them to a file.

There is an infinite loop, which checks every possible button (using GetAsyncKeyState), every 10ms, and records it to the file.

There is exception checking added in as well, for good measure.

I used Windows 8.1 x86_64, Visual Studio 2017, Modern C++17 to build the project.


Github repository link.

Author image

Windows Leak Checker

Memory Leak checking facility for Windows.

Simply integrate the files to your own program and test if you have any memory leaks.

You don't have to reference that code in your own files. It will do everything on its own, so long as you add the files to your program and compile them.

Note that it works only in debug mode!

Simple as that. : )

I used Windows 8.1 x86_64, Microsoft Visual Studio 2017 to build the project.


Github repository link.

Author image

Windows Shutdown Restart Logoff

Even wanted to have a script to shutdown/restart/sign-out your windows PC with the press of a button?

Well, now you can! Simple as that. Nothing more nothing less. The code is slim & thoroughly commented and other than some API functions which you can look up online on the Microsoft documentation (MSDN) it's pretty straightforward.

I used Windows 8.1 x86_64, Visual Studio 2017 to build the project.


Github repository link.


WIN API function

Author image

Minimal XAudio v2.8 Windows library

A high performance minimal XAudio 2.8 based library developed from scratch. It is almost as low level as one can get in Windows; such is the nature of XAudio2. I made it to use it in a Direct3D game engine but it doesn't require Direct3d and can be used for whatever purpose on the Windows platform.

XAudio2 delegates sounds to the WASAPI backend. You don't need multiple threads for each playing sound; these are managed internally by WASAPI which mixes & matches them internally as it best sees fit.

I used:

  • Windows 8.1 x86_64, Microsoft Visual Studio 2017
  • XAudio v2.8
  • X3DAudio

If you're on Windows 10 you can use XAudio v2.9 dll without much, if any, change.

If you'd prefer a more graphical approach, I have a QT audio player project.


SoundManager is a...