keystone-engine / keypatch

Multi-architecture assembler for IDA Pro. Powered by Keystone Engine.
http://www.keystone-engine.org/keypatch
GNU General Public License v2.0
1.49k stars 355 forks source link

Add install methods for IDA 7.0 windows #31

Closed SilverBut closed 7 years ago

SilverBut commented 7 years ago

Also left space for other OS.

It also can be merged together with pr #30

aquynh commented 7 years ago

merged, thanks!

enovella commented 6 years ago

Hey can you add more details in the documentation regarding PATH, versions and so on? The sentence Be sure you are installing 64-bit version is a bit vague.

SilverBut commented 6 years ago

@enovella

  1. As for the PATH. Since sometimes the Python installed by IDA installer is NOT added into the PATH, which means, you can not type in python in cmd to open a python console, you need to add those vars into your PATH. This is just to get the right binary of pip and python working. You may want to check this guide from Python's doc for more info. As for other things about PATH and versions....I did not met such problems, and please tell me if you have any.
  2. "Be sure you are installing 64-bit version" means what you need to install is an 64-bit keystone. Since both IDA, OS and Python are 64-bit ones, you need to use a 64-bit keystone to keep them compatible.

Just let me know if this reply solved your problem, and I will open another pull request if needed ;)

enovella commented 6 years ago

Hi @SilverBut,

Thanks a lot for your explanation.

I installed both python2 win32 & amd64 in my machine and add them to my PATH. However, when trying to install keystone-engine through pip, I got an error regarding keystone.so, which is a bug because I'm in a windows environment and should be keystone.dll. I have seen similar error and patched the setup.py installer. Nevertheless, I got the same error when firing up IDA with ImportError of Keystone.

It seems that the windows pip package is kinda broken. Isnt it?

Error

keystone-bug

Full log

C:\Users\eduardo\Downloads\keystone-engine-0.9.1-3-mod>C:\Python27_x64\python.ex
e -m pip install keystone-engine
Collecting keystone-engine
  Using cached keystone-engine-0.9.1-3.tar.gz
Building wheels for collected packages: keystone-engine
  Running setup.py bdist_wheel for keystone-engine ... error
  Complete output from command C:\Python27_x64\python.exe -u -c "import setuptoo
ls, tokenize;__file__='c:\\users\\eduardo\\appdata\\local\\temp\\pip-build-vdrxa
l\\keystone-engine\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f
.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" b
dist_wheel -d c:\users\eduardo\appdata\local\temp\tmpshnnmlpip-wheel- --python-t
ag cp27:
  C:\Python27_x64\lib\site-packages\setuptools\dist.py:355: UserWarning: Normali
zing '0.9.1-3' to '0.9.1.post3'
    normalized_version,
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib
  creating build\lib\keystone
  copying keystone\arm64_const.py -> build\lib\keystone
  copying keystone\arm_const.py -> build\lib\keystone
  copying keystone\hexagon_const.py -> build\lib\keystone
  copying keystone\keystone.py -> build\lib\keystone
  copying keystone\keystone_const.py -> build\lib\keystone
  copying keystone\mips_const.py -> build\lib\keystone
  copying keystone\ppc_const.py -> build\lib\keystone
  copying keystone\sparc_const.py -> build\lib\keystone
  copying keystone\systemz_const.py -> build\lib\keystone
  copying keystone\x86_const.py -> build\lib\keystone
  copying keystone\__init__.py -> build\lib\keystone
  running build_clib
  running custom_build_clib
  building 'keystone' library
  '..' is not recognized as an internal or external command,
  operable program or batch file.
  installing to build\bdist.win-amd64\wheel
  running install
  running install_lib
  creating build\bdist.win-amd64
  creating build\bdist.win-amd64\wheel
  creating build\bdist.win-amd64\wheel\keystone_engine-0.9.1.post3.data
  creating build\bdist.win-amd64\wheel\keystone_engine-0.9.1.post3.data\purelib
  creating build\bdist.win-amd64\wheel\keystone_engine-0.9.1.post3.data\purelib\
keystone
  copying build\lib\keystone\arm64_const.py -> build\bdist.win-amd64\wheel\keyst
one_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\arm_const.py -> build\bdist.win-amd64\wheel\keyston
e_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\hexagon_const.py -> build\bdist.win-amd64\wheel\key
stone_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\keystone.py -> build\bdist.win-amd64\wheel\keystone
_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\keystone_const.py -> build\bdist.win-amd64\wheel\ke
ystone_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\mips_const.py -> build\bdist.win-amd64\wheel\keysto
ne_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\ppc_const.py -> build\bdist.win-amd64\wheel\keyston
e_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\sparc_const.py -> build\bdist.win-amd64\wheel\keyst
one_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\systemz_const.py -> build\bdist.win-amd64\wheel\key
stone_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\x86_const.py -> build\bdist.win-amd64\wheel\keyston
e_engine-0.9.1.post3.data\purelib\keystone
  copying build\lib\keystone\__init__.py -> build\bdist.win-amd64\wheel\keystone
_engine-0.9.1.post3.data\purelib\keystone
  running install_data
  creating build\bdist.win-amd64\wheel\keystone_engine-0.9.1.post3.data\data
  creating build\bdist.win-amd64\wheel\Python27_x64
  creating build\bdist.win-amd64\wheel\Python27_x64\Lib
  creating build\bdist.win-amd64\wheel\Python27_x64\Lib\site-packages
  creating build\bdist.win-amd64\wheel\Python27_x64\Lib\site-packages\keystone
  error: can't copy 'src\build\llvm\lib\libkeystone.so': doesn't exist or not a
regular file

  ----------------------------------------
  Failed building wheel for keystone-engine
  Running setup.py clean for keystone-engine
Failed to build keystone-engine
Installing collected packages: keystone-engine
  Running setup.py install for keystone-engine ... done
Successfully installed keystone-engine-0.9.1.post3

C:\Users\eduardo\Downloads\keystone-engine-0.9.1-3-mod>

Patching setup.py

C:\Users\eduardo\Downloads\keystone-engine-0.9.1-3-mod>C:\Python27_x64\python.ex
e setup.py install
running install
running build
running build_py
running build_clib
running custom_build_clib
win32 & cygwin
prebuilt/win32/keystone.dll
prebuilt/win64/keystone.dll
building 'keystone' library
running install_lib
warning: install_lib: 'build\lib' does not exist -- no Python modules to install

running install_data
creating C:\Python27_x64\Lib\site-packages\keystone
running install_egg_info
Writing C:\Python27_x64\Lib\site-packages\keystone_engine-0.9.1_3-py2.7.egg-info
C:\Users\eduardo\Downloads\keystone-engine-0.9.1-3-mod>
SilverBut commented 6 years ago

@enovella Seems there do have a bug according to your log. However I can not reproduce it on neither of my VMs. Have you ever tried using keystone from the installer on the homepage instead of using pip?