一句话:在 Clang 中实现 __usercall 属性,使 C/C++ 源码能以熟悉语法直接声明用户自定义调用约定,简化逆向工程中的函数对接。
在逆向工程中,与 C/C++ 函数对接对产品开发和安全研究都很有价值,但当目标函数采用用户自定义调用约定(user defined calling convention)时,由于缺乏充分且易用的工具支持,对接一直非常困难。本文设计并实现了 Clang __usercall,提供一种优雅且熟悉的语法,让程序员可直接在 C/C++ 源码中为函数指定自定义调用约定。工作的关键新颖点在于模仿最流行的语法形式,并改造 Clang 以服务于对接(interfacing)场景。初步用户研究表明,该方案在用户体验、所需代码行数等多个关键方面优于现有方案;Clang __usercall 也已被集成到 Compiler Explorer 网站中。
In reverse engineering interfacing with C/C++ functions is of great interest because it provides much more flexibility for product development and security purpose. However, it has been a great challenge when interfacing functions with user defined calling conventions due to the lack of sufficient and user-friendly tooling. In this work, we design and implement Clang __usercall, which aims to provide programmers with an elegant and familiar syntax to specify user defined calling conventions on functions in C/C++ source code. Our key novelties lie in mimicing the most popular syntax and adapting Clang for interfacing purpose. Our preliminary user study shows that our solution outperforms the existing ones in multiple key aspects including user experience and required lines of code. Clang __usercall is already added to the Compiler Explorer website as well.
DOI 原文 ·
@inproceedings{paperbot6959,
title = {Clang __usercall: towards native support for user defined calling conventions},
author = {Jared Widberg and Sashank Narain and Yimin Chen},
booktitle = {FSE},
year = {2022},
doi = {10.1145/3540250.3558921}
}