What is the equivalent of Linux's ldd on windows? [closed] - windows

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
What is the equivalent of Linux's ldd on Windows?

Here is Dependency Walker.
http://dependencywalker.com/

The dumpbin command can be useful for many things, although in this case dependency walker is probably a little more verbose.
dumpbin /dependents some.dll
Example output:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Team Tools\Static Analysis Tools>dumpbin /dependents StanPolicy.dll
Dump of file StanPolicy.dll
File Type: DLL
Image has the following dependencies:
mscoree.dll
Summary
2000 .reloc
2000 .rsrc
1E000 .text

or the GNU tool :
i586-mingw32msvc-objdump -p *.exe | grep 'DLL Name:'

If you're using wine and not real Windows, you can use WINEDEBUG=+loaddll wine <program>.

Newer versions of Git on Windows come packaged with something called Git BASH, which emulates many useful Unix commands including ldd.
It appears that it reports only libraries that can be found. So you can use this to get an overview of where the used libraries are located, but not which are missing.

There is now an ldd in Cygwin. If you have a very old Cygwin version, you will have to use cygcheck.

I guess the Windows Developer way to do this is to use dumpbin /dependents source.exe. If you have Visual Studio installed you can find it here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\dumpbin.exe.

For Windows 10 you can use Dependencies - An open-source modern Dependency Walker
https://github.com/lucasg/Dependencies

For windows 10, with visual studio 2017, I go in the search bar of windows and type:
"developer Command Prompt for VS 2017" ( a special cmd.exe for Visual studio developer)
This allows to get access to DUMPBIN that should be used with the /IMPORTS tag. For example, in the correct directory:
DUMPBIN /IMPORTS yourfile.exe (others extension may work too)
For me, this list the DLL and the functions used.
Alternatively, you can use the tag \ALL that is much more verbose.
see the microsoft explanation of DUMPBIN:
https://learn.microsoft.com/en-us/cpp/build/reference/imports-dumpbin?view=vs-2019
Example ( with only a part) of the content sended back by the command

On Windows I use the cmder as terminal for most things (and not powershell/pwsh). For cmder you can simply type "ldd my_executable.exe" and you will see the expected output.
Link to download cmder: https://cmder.net/

Related

How to install hyperion 2.2 on kali linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I want to install hyperion 2.2 on kali linux. This version of hyperion is different than previous: there is no .cpp files (now hyperion is C). So command
'i686-w64-mingw32-c++ Hyperion-1.2/Src/Crypter/*.cpp -o hyperion.exe'
doesn't work.
I've also tried:
mingw32-make
bash: mingw32-make: command not found
Please, help.
The following command worked for me to compile with no warnings or errors. Although I have not fully tested the resulting executable yet:
i686-w64-mingw32-gcc -ISrc/Payloads/Aes/c Src/Crypter/*.c Src/Payloads/Aes/c/*.c -o hyperion.exe
Running the file command on the resulting hyperion.exe gives:
hyperion.exe: PE32 executable (console) Intel 80386, for MS Windows
i686-w64-mingw32-gcc -I Hyperion-2.3.1/Src/Payloads/Aes/c Hyperion-2.3.1/Src/Crypter/.c Hyperion-2.3.1/Src/Payloads/Aes/c/.c -o hyperion.exe
this command works for kali 2020.3 mingw-w64 V.8 and Hyperion-2.3.1
make sure to separate -I from Hyperion-2.3.1 and make sure to include full file path i.e. Hyperion-2.3.1/Src/Payloads/Aes/c/
I am the author of Hyperion. Hyperion is a Windows application and I am not very familiar with cross compiling issues on Kali Linux. Nevertheless, I can give you two hints to point you into the right direction:
If you want to use the makefile: mingw32-make: command not found means, mingw32-make is not installed. You have to use apt to install it. Something like sudo apt-get install gcc-mingw-w64 or apt install mingw-w64 should solve the issue. You can also use apt search mingw to find the corresponding package.
If you want to build it by calling the compiler yourself: The AES dll was replaced by TinyAES. It can be found here: Src/Payloads/Aes/c/aes.c. So you have to add it to your source path as well.
Kind regards,
Christian
hyperion 2.2 and 2.3 has a makefile, I change compiler gcc to i686-w64-ming32-gcc, and modify CFLAGS, it can compile.

Is there a pre-built clang library for Windows? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I am developing a tool using the clang library on Linux and I would like to port this tool to Windows.
On Linux, I can install Clang from the LLVM repositories using apt-get clang-6.0-dev and simply link my tool with -lclang. I do not need to compile LLVM and Clang myself.
Is there a way to do something similar on Windows, or do I need to compile the Clang library myself?
All of the Clang-related posts I could find are about using clang as a tool, not as a library.
I have installed the pre-build executables for Clang and LLVM from the LLVM website, and these work nicely in combination with mingw. However, the download for Windows does not seem to include the Clang library as a separate file (DLL), and linking with -lclang results in a linker error.
If there is no pre-built library for Windows, what is the best way to proceed, preferably using mingw and not MSVC?
There are pre-built LLVM/clang binaries on Zig's github page:
https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows
You can find libclang.dll in the bin folder.
The currently available versions are:
llvm+clang-6.0.0-win64-msvc-release.tar.xz
llvm+clang-7.0.0-win64-msvc-release.tar.xz
llvm+clang-8.0.0-win64-msvc-release.tar.xz
llvm+clang-9.0.0-win64-msvc-release.tar.xz
llvm+clang+lld-10.0.0-x86_64-windows-msvc-release-mt.tar.xz
There are also detailed build instructions, here.
For anyone coming to this question that's just looking to install libclang on their system, the choco llvm package appears to install libclang correctly. I can't speak to whether this is adequate for actually linking against this library for C/C++, but it worked for my case.
Just run this in an elevated command prompt or powershell:
choco install llvm
You may need to run refreshenv or open a new console for tools to pick this up.
In my case, and to help with future googlers (since I couldn't find a simple answer elsewhere) my issue was specifically while trying to compile a Rust project that made use of the onig_sys crate:
Compiling onig_sys v69.2.0
error: failed to run custom build command for `onig_sys v69.2.0`
Caused by:
process didn't exit successfully: `[redacted]\target\debug\build\onig_sys-b53394f57ee5e2c5\build-script-build` (exit code: 101)
--- stdout
cargo:warning=couldn't execute `llvm-config --prefix` (error: The system cannot find the file specified. (os error 2))
cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable
--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any valid shared libraries matching: [\'clang.dll\', \'libclang.dll\'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"', src\libcore\result.rs:1188:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
After installing llvm, the cargo build finished successfully

7-zip SFX configuration issue [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last year.
Improve this question
dI have created an archive in 7zip. (files.7z) i created a config.txt file (I actually created 3 different ones at different times). I use the command line tool to create the sfx which works fine. but when I run the .exe I do not get the expected results. It is as if the sfx ignores the config.
I put the archive and config.txt in the 7-zip install directory and my command line looks like this:
C:\Program Files\7-Zip>copy /b 7z.sfx + config.txt + files.7z files.exe
When I run that the result looks like this
7z.sfx
config.txt
files.7z
1 file(s) copied.
Here is my config. I used notepad and made sure to save as UTF-8.
;!#Install#!UTF-8!
Title="MyApp Installer"
ExecuteFile="setup.exe"
InstallPath="%temp%\\My App"
;!#InstallEnd#!
I copy the files.exe to desktop in a folder. Run and it asks me where to extract, won't run the setup.exe (in the files.7z root)
What am I doing wrong? Ive been all over the 7-zip forum and can't find my error.
You're using the wrong SFX module -- you need to use 7zS.sfx instead of 7z.sfx . IIRC, 7zS.sfx doesn't come with 7-Zip by default, you have to download the 7z<ver>-extra.7z archive from SourceForge to get it.
According to the -sfx (Create SFX archive) switch and Command Line Version User's Guide:
SFX_Module - Specifies the SFX module that will be combined with the
archive. This module must be placed in the same directory as the
7z.exe. If SFX_Module is not assigned, 7-Zip will use standard
console SFX module 7zCon.sfx.
The whole process of creating installer is well documented, including an example of the config file and batch file you need to use to pack the installer. It's what you already did and posted here.
There is also a description of which module you need for the particular use-case:
SFX_Module Description
7z.sfx SFX module (GUI version)
7zCon.sfx SFX module (Console version)
7zSD.sfx SFX module for installers (GUI version)
7zS2.sfx small SFX module for installers (GUI version)
7zS2con.sfx small SFX module for installers (Console version)
The file that can be used to pack an installer / .exe project is 7zSD.sfx or 7zS.sfx.
They are both made for installers. Use it if you want to create a self-extracting archive that performs the installation, extracts archive to the temporary folder during the installation, runs the specified program and cleans the temporary files up after the installation is done.
The difference between them is:
7zSD.sfx uses MSVCRT.dll, which is the C standard library for the Visual C++ (MSVC) compiler from version 4.2 to 6.0. Your self-extracting archive won't run on pure, old Windows if some other application didn’t install MSVCRT.dll on that machine. It is included with every modern Windows installation, on top of which most Windows applications are built.
Since you should be safe now days about MSVCRT.dll, using both 7zS.sfx and / or 7zSD.sfx is ok, just pick one and things should work smoothly.
There is no need to download via SourceForge anymore. In current versions of 7-Zip, the required .sfx file is not part of 7z-Extra download, it is part of the LZMA SDK.
https://www.7-zip.org/sdk.html
You need to extract LZMA SDK and copy 7zS.sfx and / or 7zSD.sfx next to the 7z.exe.

Linux tools to inspect Windows DLLs

I have to debug a problem with Windows DLLs, but I'm running Linux exclusively, so I was wondering whether there are (preferably command-line) tools to inspect Windows DLLs under Linux. What I'm looking for is mainly the list of exported symbols.
Use "winedump -j export file.dll"
winedump is part of Wine
Homepage:
https://www.winehq.org/docs/winedump
Have you checked if Dependency Walker will work under wine?
http://dependencywalker.com/
(just a WAG)
How to use it on the command line (Run it from the same directory as the DLL):
wine /full/path/to/depends.exe /c /of:output.txt dynamic-library.dll
https://github.com/knik0/peinfo
works nicely. Tested with several Windows DLLs 64 bits

Is there a way to run Bash scripts on Windows? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have bought and I use Windows 7 Ultimate, and I like to use it to develop applications. One of the down sides (as with every OS) is that I can not run Bash scripts. Is there a way to run Bash scripts on Windows by installing some software? It is ok if it does not work 100%, but as long as the most common functionality is available it should be great.
Install Cygwin, which includes Bash among many other GNU and Unix utilities (without whom its unlikely that bash will be very useful anyway).
Another option is MinGW's MSYS which includes bash and a smaller set of the more important utilities such as awk (you may also want to check the competing fork - Mingw-w64). Personally I would have preferred Cygwin because it includes such heavy lifting tools as Perl and Python which I find I cannot live without, while MSYS skimps on these and assumes you are going to install them yourself.
Updated:
If anyone is interested in this answer and is running MS-Windows 10, please note that MS-Windows 10 has a "Windows Subsystem For Linux" feature which - once enabled - allows you to install a user-mode image of Ubuntu and then run Bash on that. This provides 100% compatibility with Ubuntu for debugging and running Bash scripts, but this setup is completely standalone from Windows and you cannot use Bash scripts to interact with Windows features (such as processes and APIs) except for limited access to files through the DrvFS feature.
Best Option I could find is Git Windows Just install it and then right click on and click "Git Bash Here" this will open a bash window
This will open a bash window like this:
and the linux commands work...
I've tried 'sh' , 'vi' , 'ssh' , 'curl' ,etc... commands
If you're looking for something a little more native, you can use getGnuWin32 to install all of the Unix command line tools that have been ported. That plus winBash gives you most of a working Unix environment. Add console2 for a better terminal emulator and you almost can't tell you're on Windows!
Cygwin is a better toolkit overall, but I have found myself running into surprise problems because of the divide between it and Windows. None of these solutions are as good as a native Linux system though.
You may want to look into using virtualbox to create a linux VM with your distro of choice. Set it up to share a folder with the host os, and you can use a true linux development environment, and share with windows. Just watch out for those EOL markers, they get ya every time.
Best option? Windows 10. Native Bash support!
You can always install Cygwin to run a Unix shell under Windows. I used Cygwin extensively with Window XP.
After installing git-extentions (http://gitextensions.github.io/) you can run .sh file from the command prompt. (No ./script.sh required, just run it like a bat/cmd file)
Or you can run them in a "full" bash environment by using the MinGW Git bash shell.
I am not a great fan of Cygwin (yes I am sure it's really powerful), so running bash scripts on windows without having to install it perfect for me.
In order to run natively, you will likely need to use Cygwin (which I cannot live without when using Windows). So right off the bat, +1 for Cygwin. Anything else would be uncivilized.
HOWEVER, that being said, I have recently begun using a combination of utilities to easily PORT Bash scripts to Windows so that my anti-Linux coworkers can easily run complex tasks that are better handled by GNU utilities.
I can usually port a Bash script to Batch in a very short time by opening the original script in one pane and writing a Batch file in the other pane. The tools that I use are as follows:
UnxUtils (http://sourceforge.net/projects/unxutils/)
Bat2Exe (http://bat2exe.net/)
I prefer UnxUtils to GnuWin32 because of the fact that [someone please correct me if I'm wrong] GnuWin utils normally have to be installed, whereas UnxUtils are standalone binaries that just work out-of-the-box.
However, the CoreUtils do not include some familiar *NIX utilities such as cURL, which is also available for Windows (curl.haxx.se/download.html).
I create a folder for the projects, and always SET PATH=. in the .bat file so that no other commands other than the basic CMD shell commands are referenced (as well as the particular UnxUtils required in the project folder for the Batch script to function as expected).
Then I copy the needed CoreUtils .exe files into the project folder and reference them in the .bat file such as ".\curl.exe -s google.com", etc.
The Bat2Exe program is where the magic happens. Once your Batch file is complete and has been tested successfully, launch Bat2Exe.exe, and specify the path to the project folder. Bat2Exe will then create a Windows binary containing all of the files in that specific folder, and will use the first .bat that it comes across to use as the main executable. You can even include a .ico file to use as the icon for the final .exe file that is generated.
I have tried a few of these type of programs, and many of the generated binaries get flagged as malware, but the Bat2Exe version that I referenced works perfectly and the generated .exe files scan completely clean.
The resulting executable can be run interactively by double-clicking, or run from the command line with parameters, etc., just like a regular Batch file, except you will be able to utilize the functionality of many of the tools that you will normally use in Bash.
I realize this is getting quite long, but if I may digress a bit, I have also written a Batch script that I call PortaBashy that my coworkers can launch from a network share that contains a portable Cygwin installation. It then sets the %PATH% variable to the normal *NIX format (/usr/bin:/usr/sbin:/bin:/sbin), etc. and can either launch into the Bash shell itself or launch the more-powerful and pretty MinTTY terminal emulator.
There are always numerous ways to accomplish what you are trying to set out to do; it's just a matter of combining the right tools for the job, and many times it boils down to personal preference.
There's one more theoretical possibility to do it: professional versions of Windows have built-in POSIX support, so bash could have been compiled for Windows natively.
Pity, but I still haven't found a compiled one myself...

Resources