Generating a 32-bit import library is more complex because 32-bit functions use name decoration (e.g., CiFreePolicyInfo@4) based on argument byte sums, while ci.dll exports functions in their non-decorated shape. To bridge this, you must provide an object file containing function stubs that mimic the expected signatures.
- Extract exports and create a
.def file as you would for 64-bit. - Create a C++ stub file: Implement the functions with the correct signatures but dummy bodies (e.g., returning
nullptr). - Compile the stub to an
.obj file: Use cl with appropriate kernel and CRT include paths. - Generate the
.lib file: Use the lib utility, including the newly created .obj file.
// Example stub in CI.Stub.cpp
_IRQL_requires_max_(PASSIVE_LEVEL)
PVOID
NTAPI
CiFreePolicyInfo(
_In_ MINCRYPT_POLICY_INFO* PolicyInfo
)
{
UNREFERENCED_PARAMETER(PolicyInfo);
return nullptr;
}
# Compile the stub
SET KM_IncludePath="C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\km"
SET CRT_IncludePath="C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\km\crt"
SET KIT_SHARED_IncludePath="C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared"
cl CI.Stub.cpp /c /kernel /Zc:wchar_t /I%KM_IncludePath% /I%CRT_IncludePath% /I%KIT_SHARED_IncludePath% /D _X86_=1 /D i386=1 /DSTD_CALL /D_MINCRYPT_LIB
# Generate the .lib file using the OBJ
lib /def:CI.def /machine:x86 /out:ci.lib CI.Stub.obj