ptxNinja: decompilation for PTX (CUDA)

ptxNinja is an architectural plugin that extends the functionality of Binary Ninja to support *.ptx files containing functions or kernels written in PTX. The PTX language is a low-level format used by NVIDIA for its CUDA-based GPUs. This plugin provides a lifter that translates raw instructions into the low-level instructions that Binary Ninja requires to begin analysis.

Binary Ninja allows you to implement a translator, called lifter, to convert each “raw” instruction into a format compatible with the decompiler, called Low Level Intermediate Language (or LLIL). The translation from raw to the low level is 1 to 1, meaning that every instruction should have the correspondent concrete semantics. As shown in the following image, implementing this component enables the decompilation of PTX, up to the high level and possibly even pseudo-C.

Lifter and several translations from binary ninja

For example, using a CUDA kernel that implements a simple matrix multiplication, you can see how the high-level algorithm is translated into PTX instructions and vice versa.

Matrix multiplication-based kernel

The developed plugin has applications in the fields of semi-formal verification, analysis of malware targeting the CUDA architecture, and R&D on compiler transformations. The work was presented at RE//verse 2026 conference (recording) where I discuss possible improvements for a possible decompiler that targets CUDA.

Contact me