wargio/r2dec-js

the pdd command outputs just the assembly code

Harshiv-Patel opened this issue · 21 comments

OS : Windows 10 , arch x64
Radare2 version: 4.4.0 24350 @ windows-x86-64

So I built the source with meson build , cd build , and meson compile which completed without any errors,
Then I copied the whole folder (named r2dec-js-4.4.0 ) to dir pointed by radare2.exe -H R2_RDATAHOME
Which in my case is
C:\Users\Harshiv\.local\share\radare2\
The r2pm\git directory structure wasn't there, so I created it.
Copied the r2dec folder with built library file (under r2dec-js-4.4.0\p\build\libcore_pdd.dll )
To the created folder,

and opened my file of interest r2 libmain.so
Did af followed by pdd , and it printed the assembly output.
cropped

I also tried the cutter's "radar2/plugin" version of the core_pdd.dll, with same result.

Am I missing something here?

The so library is of arch armv7,Android.
When that didn't work, I tried setting the environment variable R2DEC_HOME, pointing to the "r2dec-js-4.4.0" directory, this also didn't work.

i think the library was not installed correctly. how did you install it?

libcore_pdd.dll needs to be copied into the r2 plugins folder.

q8ing commented

I opened an old issue regarding this in windows, still can't get it to work in windows without cutter, I installed the library correctly and everything is fine, but when I run pddf, It crashes without any reason.
Here is some pictures related to this problem, I am still using cutter instead of compiling it by myself, I compiled the source code with Mingw64.
1
2
3
4

Wish you best luck :)

Is your radare compiled with the same compiler as the plugin? Are you using the ci builds from r2. I will add the ci job to build the mac, debian and windows plugins for r2dec. I dont have windows to test but i will test it in the ci and see if it works or not.

i feel like what @trufae said might be correct. looks like a version mismatch, but if it doesn't crash with pdd? then can be a bug on r2dec itself.
can you provide the pddi output? if not the binary?
If you do not want to share the binary here, you can find me on the radare telegram channel or you can send me an email.

See #231

q8ing commented

I built them both using Microsoft visual studio 2019 (Cl) instead of using mingw64 for building the plugin and visual studio 2019 for radare2. A error message appeared instead of a sudden crash.

11

My radare2 is built using two commands:
1- "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
2- python sys\meson.py --release --backend vs2019 --shared --install --prefix %cd%\dist --webui

My r2dec plugin is built using two commands:
1- meson C:\Users\root.local\share\radare2\r2pm\git\r2dec-js\p
2- ninja

I moved core_pdd.dll to C:\Users\root.local\share\radare2\plugins
and core_pdd.lib C:\Users\root\AppData\Local\Programs\radare2\dist\lib\plugins

C:\Users\root\Desktop>radare2 -H
R2_VERSION=5.1.0
R2_PREFIX=.
R2_MAGICPATH=C:\Users\root\AppData\Local\Programs\radare2\dist\share\magic
R2_INCDIR=C:\Users\root\AppData\Local\Programs\radare2\dist\include\libr
R2_LIBDIR=C:\Users\root\AppData\Local\Programs\radare2\dist\lib
R2_LIBEXT=dll
R2_RCONFIGHOME=C:\Users\root.config\radare2
R2_RDATAHOME=C:\Users\root.local\share\radare2
R2_RCACHEHOME=C:\Users\root.cache\radare2
R2_LIBR_PLUGINS=C:\Users\root\AppData\Local\Programs\radare2\dist\lib\plugins
R2_USER_PLUGINS=C:\Users\root.local\share\radare2\plugins
R2_USER_ZIGNS=C:\Users\root.local\share\radare2\zigns

I created env variable R2DEC_HOME that points to C:\Users\root.local\share\radare2

I also moved the entire r2dec-js folder to C:\Users\root.local\share\radare2\r2pm\git
because I though maybe the problem is related to env variable that I created earlier.

Here is the compiled files.

Files.zip

Thank you very much for your assistance :>

i'm not sure if that is a bug on r2dec or r2. if you run aflj on r2 does it crash ?

q8ing commented

No, It won't crash with aflj.

Here is some pictures:
1
2
3
4

radare2.zip
plugin.zip

I uploaded the entire build here with the plugin too, you can test them by yourself :)
Thank you very much.

Can you Try with the binaries generated in the ci

q8ing commented

Yeah, I tested your generated binaries (r2dec-5.1.0_w64.zip).

It generated the same error as above in the pictures.

q8ing commented

I installed radare2 using the installer (5.1.0) instead of compiling It by myself, moved .dll file and plugin directory to correct locations, after that I used pdd?
Guess what?
It is showing assembly code only instead of the plugin options.
I figured out that the installer doesn't contain radare2 .dll files, so i used radare2-5.1.0_w64 instead of radare2-windows-installer.exe

It produced the same error with r2dec and also the same error is produced with cutter r2cutter-0.1.1_w64.

1

can you share the binary?

q8ing commented

can you share the binary?

I didn't compile anything by myself this time, I used the official releases available in repos, Here is the links:

https://github.com/radareorg/radare2/releases/download/5.1.0/radare2-5.1.0_w64.zip

https://github.com/radareorg/r2cutter/releases/download/0.1.1/r2cutter-0.1.1_w64.zip

https://github.com/wargio/r2dec-js/actions/runs/532391106#artifacts

For r2dec, I tested trufae compiled binary, still getting the same error.

i don't know what you are doing, but i can't even load the library with the artifacts, on windows.
https://github.com/radareorg/radare2/releases/download/5.1.0/radare2-5.1.0_w64.zip
https://github.com/wargio/r2dec-js/actions/runs/532391106#artifacts

q8ing commented

image

I didn't load the library, I just moved it to radare2 plugin folder, created env variable as mentioned in the instructions and used pdd? command.

yes, i did the same as you can see. but still, it doesn't work for me. i'll try again later.

q8ing commented

Here is a step by step for what I did, I uploaded the files too.

1
2
3
4
5
6
7
8
9
10
11
12
13
radare2-5.1.0_w64.zip
r2dec-5.1.0_w64.zip.zip

look how cutter went through the same problem. I think windows version is not tested well :>
I am using Windows 10 (20H2).

Thank you very much for your time.

This bug was fixed.