While there’re easy to just run make from Linux or MacOS to compile IDA plugin, in Windows, they got much off error, so after I modify sdk to success compile on Windows, I notes here for who need it. Hope it help.
First of all, need to install cygwin as is required to use unix make https://www.cygwin.com/, in IDA7, could use cygwin64, install make package from cygwin package manager.
Add Cywin path to the system variable PATH (Control Panel / System / Advanced System Settings / Tab Advanced / Enviroment Ariables …)
or in the Command Prompt
After settup, you could test the command by run C:\cygwin64\cygwin.bat from driver and call the make command.
Second, install Visual Studio 2017 (I use Enterprise Version), Window SDK 10.0.10240.0, Windows C++ Build 15 for Visual Studio, Windows Kit 10
Install perl for Windows and add it binary to PATH environment.
Install Python 2.7 x64 for Windows.
Third, modify some make file.
allmake.mak
Line 119 – 428
Line 442 – 447
Line 468
Line 544 – 548
default.mak
Line 31
Line 44 – 47
Line 53 – 56
Line 60 – 63
makeenv_vc.mak
Line 6 – 11
Line 57
Open the Visual Studio Command Prompt x64 Console, run cygwin.bat from C:\cygwin64\cygwin.bat, cd to idasdk70 directory
the x64_win_vc_32.cfg will be created in the sdk directory, if you want to build all plugins, you could run
To compile ida64 plugins use the command
or you can cd to plugins directory and compile plugin yo want.
I attach the modified sdk below.
P/S: IDA 7.0 has a bug while debug x86 pe (on windows 10 build after 2017), it crash and not show any error, this error can be fix by comment line 394 in winbase_debmod.cpp and rebuild the win32_user.dll
IDAPython could be build, only need modify some .i file to exclude the error.
First of all, need to install cygwin as is required to use unix make https://www.cygwin.com/, in IDA7, could use cygwin64, install make package from cygwin package manager.
Add Cywin path to the system variable PATH (Control Panel / System / Advanced System Settings / Tab Advanced / Enviroment Ariables …)
Code:
C:\cygwin64\bin
or in the Command Prompt
Code:
set PATH=C:\cygwin64\bin;%PATH%
Second, install Visual Studio 2017 (I use Enterprise Version), Window SDK 10.0.10240.0, Windows C++ Build 15 for Visual Studio, Windows Kit 10
Install perl for Windows and add it binary to PATH environment.
Install Python 2.7 x64 for Windows.
Third, modify some make file.
allmake.mak
Line 119 – 428
Code:
else ifdef __X64__ # Visual Studio for AMD64
COMPILER_NAME=vc
ifdef __VC8__
SDK_LIB1=/LIBPATH:"$(MSSDK)lib/x64"
else
SDK_LIB1=/LIBPATH:"$(WSDK_LIB)um/x64"
SDK_LIB2=/LIBPATH:"$(WSDK_LIB)ucrt/x64"
endif
TARGET_PROCESSOR_NAME=x64
CC ="$(MSVCDIR)bin/amd64/cl.exe"
Line 442 – 447
Code:
endif
_LIBRTL="$(MSVCDIR)lib/amd64"
LINKOPTS_EXE=/LIBPATH:$(_LIBRTL) $(SDK_LIB1) $(SDK_LIB2) $(_LNK_EXE_MAP) $(LNDEBUG) $(LNKERREP)
LINKOPTS=$(LNOUTDLL) $(LINKOPTS_EXE) $(_LSHOW)
#_LINKER =$(LDEXE) _v _l"$(MSVCDIR)bin/amd64/link.exe"
_LINKER ="$(MSVCDIR)bin/amd64/link.exe"
#CCL =$(LDEXE) _v _l$(CC) _a"/link $(LINKOPTS_EXE) $(CCL_LNK_OPT) $(_LDFLAGS)" $(CFLAGS)
CCL =$(CC) /link $(LINKOPTS_EXE) $(CCL_LNK_OPT) $(_LDFLAGS) $(CFLAGS)
Code:
AR =$(RS)ar$(BS) _e.at _v _l"$(MSVCDIR)bin/amd64/lib.exe" $(_LBSHOW) $(AROPT)
Line 492
LINKOPTS_EXE=/LIBPATH:$(MSVCARMDIR)lib/armv4 /LIBPATH:$(ARMSDK)lib/armv4 $(LNDEBUG)
Line 523 – 530
ifdef __VC8__
SDK_LIB1=/LIBPATH:"$(MSSDK)lib"
else
SDK_LIB1=/LIBPATH:"$(WSDK_LIB)um/x86"
SDK_LIB2=/LIBPATH:"$(WSDK_LIB)ucrt/x86"
endif
TARGET_PROCESSOR_NAME=x86
CC ="$(MSVCDIR)bin/cl.exe"
Code:
LDFLAGS+=$(_LDFLAGS)
LINKOPTS_EXE=/LIBPATH:"$(_LIBRTL)" "$(SDK_LIB1)" "$(SDK_LIB2)" $(_LNK_EXE_MAP) $(LNDEBUG) /LARGEADDRESSAWARE /DYNAMICBASE
LINKOPTS=$(LNOUTDLL) $(LINKOPTS_EXE) $(_LSHOW) $(LNDEBUG)
#_LINKER =$(LDEXE) _l"$(MSVCDIR)bin/link.exe"
_LINKER ="$(MSVCDIR)bin/link.exe"
#CCL =$(LDEXE) _v _l$(CC) _a"/link $(LINKOPTS_EXE) $(LDFLAGS)" $(CFLAGS)
CCL =$(CC) /link $(LINKOPTS_EXE) $(LDFLAGS) $(CFLAGS)
Line 574
AR =$(RS)ar$(BS) _e.at _v _l"$(MSVCDIR)bin/lib.exe" $(_LBSHOW) $(AROPT)
Line 31
Code:
shortdospath=$(subst \,/,$(shell cygpath -d $(1) 2>/dev/null))
Code:
export WSDKPATH
#ifeq (,$(wildcard $(WSDKPATH)))
# $(error Windows SDK not found in $(wildcard $(WSDKPATH)) (see defaults.mk))
#endif
Code:
export WSDK_INCLUDE
#ifeq (,$(wildcard $(WSDK_INCLUDE)))
# $(error Windows SDK version $(WSDKVER) not found (see defaults.mk))
#endif
Code:
export WSDK_LIB
#ifeq (,$(wildcard $(WSDK_LIB)))
# $(error Windows SDK version $(WSDKVER) not found (see defaults.mk))
#endif
Line 6 – 11
Code:
ifneq ($(__VC8__)$(__VC10__),)
SDK_INCLUDE1=/I"$(MSSDK)Include"
else
SDK_INCLUDE1=/I"$(WSDK_INCLUDE)um"
SDK_INCLUDE2=/I"$(WSDK_INCLUDE)shared"
SDK_INCLUDE3=/I"$(WSDK_INCLUDE)ucrt"
Code:
/I"$(MSVCDIR)Include"
Code:
make env
Code:
./bin/idamake.pl
Code:
export __EA64__ = 1
make env
make NDEBUG=1 __NT__=1 __EA64__=1
or you can cd to plugins directory and compile plugin yo want.
I attach the modified sdk below.
P/S: IDA 7.0 has a bug while debug x86 pe (on windows 10 build after 2017), it crash and not show any error, this error can be fix by comment line 394 in winbase_debmod.cpp and rebuild the win32_user.dll
Code:
bool ntdll_vec_t::add(eanat_t addr, size_t sz, HANDLE h)
{
if ( has(addr) )
return false;
// max number of ntdlls: ntdll32.dll and ntdll.dll
//QASSERT(1491, size() < 2); // <-- line 394
ntdll_range_t &r = push_back();
r.start = addr;
r.end = addr + sz;
r.handle = h;
return true;
}
IDAPython could be build, only need modify some .i file to exclude the error.
Attachments
Last edited: