Is it possible to make MS visual C++ compiler treat Win32 API import calls as (unresolved) external symbols?
In other words, I need to change dword ptr
calls which reference to some IAT, e.g.:
FF 15 00 00 00 00 call dword ptr [__imp__MessageBoxA@16]
to external symbol calls, e.g.:
E8 00 00 00 00 call _MessageBoxA@16
This implies that after the compilation I don't need linking, because obviously it won't be possible. So as a product I want to get (MS) COFF .obj
files which such unusual calls of Win32 API.
As it was pointed out in the comments under the question, the reason why Win32 API calls are compiled into
call [__imp__xxx]
is__declspec(dllimport)
.So to achieve what was asked in the question, all Win32 API functions must defined without
__declspec(dllimport)
.In the Win32 header files (such as
WinUser.h
) you can see that all functions are defined withWINxxxAPI
macro, which in turn are defined inapisetcconv.h
. In the later fileWINxxxAPI
macros are defined withDECLSPEC_IMPORT
, which in turn is defined as__declspec(dllimport)
.So, an easy way to achieve the requirement is to re-define
DECLSPEC_IMPORT
with the following empty preprocessor definition ( see /D flag ):Which is equivalent to
P.S. If there are alternative ways, I would still like to know them.