Is it possible to use Java to retrieve assembly version(DLL)? - c#

I recently pickup Java so I have very limited knowledge, but I would like to know if it's possible to get DLL version using Java. If it is not possible, is it possible to use C# to get Jar version through the manifest file?

It's certainly possible in each case - you just need to write code to read the appropriate file format.
I suspect it's vastly simpler to find the manifest in a jar file from C# than the assembly version from Java though - it's just a case of loading a zip file and finding the META-INF/MANIFEST.MF file. Reading the file is easy, as it's plain text.
Depending on exactly what you mean by the version of a DLL, you may need to do all manner of things - if you're talking about .NET assembly attributes, I don't know whether they're placed in some easily-fetchable place; my experience of parsing Portable Executable (PE) files is that it's slightly tricky unless you've got library support. Of course if you can find a Java library which knows the format already, it may become trivial...

Related

Decompling .net assembly

Hey i have done a few of decompiling in .net as i am learning c# so it helps me to see codes as it helps a lot. But lately i have come acrossed few program that i know are .net but in reflector show up as non .net assemblies. Here is the example of program named: Proxy Multiply.
I am not trying to do any illegal stuff or something. Just trying to learn. I have tried to google this but i was not able to achieve any good result.
Thanks
here is the link to image.
There are many .Net code protection alternative, that obfuscate the IL codes so that they are not that much exposed to IL disassembler application.
.Net Reactor
Themida
SmartAssembly
the list is huge . . .
many of the protector modify the Exe (PE Header info), .Net exe contains some extra MetaData that helps disassembler to identify it.
Download this little application it may tell you a little more about the exe.
Download PEiD 0.95
PEiD is an intuitive application that relies on its user-friendly
interface to detect packers, cryptors and compilers found in PE
executable files – its detection rate is higher than that of other
similar tools since the app packs more than 600 different signatures
in PE files.
PEiD comes with three different scanning methods, each suitable for a
distinct purpose. The Normal one scans the user-specified PE file at
its Entry Point for all its included signatures. The so-called Deep
Mode comes with increased detection ratio since it scans the file's
Entry Point containing section, whereas the Hardcore mode scans the
entire file for all the documented signatures.
My best guess the assembly you are looking for is Protected by .Net Reactor or Themida
I have same problem with dot net reflector before,
try JetBrains dotPeek version 1.0 Decompling(this application will show code that obfuscated)
Decompiling .NET 1.0-4.5 assemblies to C#
Support for .dll, .exe, .zip, .vsix, .nupkg, and .winmd files
Quick jump to a type, assembly, symbol, or type member
Effortless navigation to symbol declarations,
implementations, derived and base symbols, and more
Accurate search for symbol usages
with advanced presentation of search results
Overview of inheritance chains
Support for downloading code from source servers
Syntax highlighting
Complete keyboard support
dotPeek is free!
Just because it is .NET doesn't mean that you can just decompile it like that. They probably used ILMerge. That's not to say it's impossible but it will require more work.
See Is it possible to “decompile” a Windows .exe? Or at least view the Assembly?

How to compile c#/c++ files from Java Application

I am just looking into compilers and I was wondering is it possible to compile both c# and c++ files from a Java Application (e.g. to compile java from a java application you can use the JavaCompiler API). I have looked online for this but all i can find is ways to compile java files from c# and c++ and not the other way around.
If so, what API's can you use for this?
If you know the system commands for compiling and executing .cpp files(don't know much about c#) you might want to check out this. It details how to execute system commands from a Java program. Pass the system commands for compiling the required file in Runtime.getRuntime().exec().
Consider learning how to call ant from Java code and using something like this ant enhancement.
Disclaimer: I don't know anything about this product, but found it by searching for "can ant build c++?"
For C# in Windows: compiler (csc.exe) is part of .Net install on Windows and can be found at well known location (like %windir%\Microsoft.NET\Framework\v3.5 for .Net 3.5). The same place also contains MSBuild.exe that can build project files (*.csproj).
Your code may need to provide locations for referenced libraries if using Csc.exe to compile individual files.

What language is Mono written in and how do I read the source code?

I want to read the source code for Mono. I looked up this URL and there are several folders here.
What language is the Mono project written in?
Which folder/file do I download to read its source?
From looking at the folder hierarchy, it appears (although my assumption could be wrong) that it has been written in several languages and that I could download any one of them.
But I'd just like to make sure.
You'll want the mono subdirectory, pick the version you are interested in.
The equivalent of the CLR and the jitter were written in C. You'll find it in the mono/mini subdirectory.
The C# compiler was written in C#. You'll find it in the mcs/mcs subdirectory.
The framework classes were written in C#. You'll find them in the mcs/class subdirectories.
For the most part, C#. There is a page on the Mono website that talks about the various languages. So look here: MonoProject - Languages

Building C# App with Internal DLLs

Is there a way to keep any DLLs needed for my Visual C# program (such as SQLite) inside the actual EXE so it doesn't require the files to be present?
If not, can anyone show me how to make a wrapper for my program (independent of .NET, so maybe C++?) to copy/load required files to the working directory before starting the program itself.
What I intend to end up with is a single EXE file that can be deployed anywhere and set itself up like a transformer. All it requires is the following criteria:
SQLite is present
OpenHardwareMonitorLib is present
.NET 2.0 is installed (if not, offer install with redistributable package)
Microsoft provide a tool for merging DLLs. It's called ILMerge.
It doesn't always work, I believe certain things can cause problems. But it's definitely the easier option!
If the problem is redistribute only one file, you can create a "installer" exe, that unpack all your dependencies (from executable content).
If you don't want to leave all dlls in your production environment, you can merge all IL code in the main executable. you can use ILMerge (but it's not the only product that can do this)
You can merge the dependencies into the main executable. After your build completes you run an additional tool that combines the IL code into a single assembly.
ILMerge can do this but is a bit cumbersome to use.
Some (proprietary) tools can do this as well. I know of at least one obfuscator (DeepSea) that can do this. DeepSea also allows you to specify what you want to include and what types you want to expose from the resulting assembly.
Full disclosure: I know the guys that build DeepSea Obfuscator.
I guess you could embed the target assemblies as resources and then unpack them in some custom assembly resolution code?
Edit: there's an example of this here: Embedding assemblies inside another assembly

Handling Zip Files Without Third Party Lib in .NET 4.0?

There is a similar question for 3.5 here:
Is there a built-in zip library in .NET 3.5?
that speculated that 4.0 would have it, but I can't find any info about it. If not, does anyone know why not? Seems like it would be fairly high on the list of things to include support for.
Take a look at the System.IO.Packaging namespace, which contains support for ZIP files, but not all of the features of ZIP files.
Still, it might be enough for your needs.
You may have already moved along, but ZiP API is added in .NET 4.5
http://msdn.microsoft.com/en-us/library/system.io.compression.ziparchive.aspx
go nuts.
Not for 4.0, but a ZipArchive class is being considered for the next version. You can find details about this on the BCL Team blog.
Edit: Otherwise, assuming that it's still available, and depending on your definition of built in (at least it comes/came with Visual Studio), you might be able to use the J# classes to zip files as described in this article: Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#
Edit2: Though note the comments below, that the J# option is probably not the right option except in certain unusual circumstances.
Most easiest to deal with, is with sample code here.
You need to add a new assembly just to find he Zip archive.
Working with Zip files in .NET 4.5

Categories