.Resources file "extraction"? - c#

I have a project I was working on and a few weeks ago I had to restore my PC, I opened up the project today only to see I don't have all the images because it was all on my desktop. I have a load of files I didn't see before that are called things like "frmMain.resources", I'm assuming all the images in my project are in those files. Is there any way I could view these files and extract my image files out?
Thanks in advance
-Neel

I mentioned ILSpy but it seems the latest version has the ability to save the resources from an assembly, requiring no extra tools.

Related

DLLs not working after installing Visual Studio Setup Project

I have a C# project that I am creating which uses a few DLLs located in a separate folder in my project. I have added these files into the application folder on the file system viewer in the installer project.
Everything seems to work fine, it builds properly and doesn't show any big errors.
However, after I try to install my application, it is way smaller than it should be (8.24 MB compared to over 400 MB). I believe the issue arises when I try to open the Microsoft Azure Kinect camera. An error pops up when I do this saying the device could not be opened. This is strange to me because the program runs just fine in debug mode in Visual Studio, meaning the camera is plugged in properly and works.
I compared some of the DLL files from a working, older version that a consultant had made (they created an installer that works fine on my computer). The file sizes were drastically different for these DLLs.
For reference:
File Size Differences
I have tried redoing the installer, deleting and re-adding the DLLs, and overwriting the bigger files into my application after installation. I have the SDKs for the Kinect downloaded on my computer. I am also not an administrator for this computer as it is not my personal computer. Another note, the installer from the consultant works fine, however when I try to download the source code that installer came from and try to install it from there, the same issue happens.
The video the consultant used to create the installer is this: https://youtu.be/6Mfp2EXmVNI
I followed this tutorial as well, but same issue.
This is a summary of my comments above
So it looks like you are using Git Large File System (LFS). You currently only have placeholder files. With a Git LFS repo a git pull only grabs non-LFS files whilst leaving placeholder files for everything else. You need to tell Git LFS to actually download them proper.
Try:
git lfs pull
Some Git GUI clients will do this for you automatically.
OP:
...which uses a few DLLs located in a separate folder...
BTW, if these files are essentially static consider adding them to Git as non-LFS files then you can grab them like any other files in your Git repo. LFS is only "useful" if the files will be changing a reasonable number of times and then you have to ask yourself is it really worth it.
See also
git-lfs-pull(1) -- Download all Git LFS files for current ref & checkout

Restore .cs files from debug folder generated for a ASP.NET Core application

I have been programming an ASP.NET Core application for the last couples of weeks. Just a "small project" to put on my resume so I can get my first job. But today when I tried to upload it to Github I somehow deleted all the .cs files which really suck big time! However, I still have the files from the bin/debug folder in the original folder where all the .cs files was. Is there any way to restore the .cs files? I have been trying to use .NET Reflector but without any luck because I don't know how it works.
I don't know what information is relevant to know, so please feel free to ask for more details!
Best Regards
Christian
ILSpy might be easier to use. Just load the binary and it will decompile each type. You can just copy-paste the code.

How to reverse engineer an .exe that uses a .resource file to store an assembly?

Context
I work as a game developer at a studio that develops an MMO. We built an authoritative server but still run into issues with exploits and automation. I downloaded the main bot used to hack our game in an effort to determine how it exploits our server so we can patch accordingly.
Question
I decompiled the .exe using dotPeek to get the source files but ran into an issue: I only got the source files for the launcher. The launcher injects the core assembly into our application at runtime. It does so by storing the assembly as hex data in a .resource file. Any idea of how I can get the source code from this .resource file?
Solution
Thanks for everyone's help. I got the source files by extracting the binary data from the .resource file and writing it to a .dll file and then decompiling it using dotPeek. See my solution for more details.
Shouldn't you be able to use GetManifestResourceStream to get the embedded data?
Thanks everyone for the help - a combination of using a decompiler and reading the binary assembly data at runtime and writing it to a .dll file helped me get the source code:
I used dotPeek to decompile the launcher. In assembly explorer, I then right clicked the assembly and selected Export to Project... I then opened the project in Visual Studio and inserted a line that used File.WriteAllBytes to write the the byte[] (already available via their application, but this just got the binary data from the .resource file using ResourceManager.GetObject) to a .dll file. I then opened that .dll file in dotPeek and wala - source code visible.
I recommend designing around the problem, a kind of soft-captcha enforced by the server. The truth of your problem is: .Net is open to extension. Rather than engage in a 'cat and mouse arms race' around the client exe, think about how you detect non-human activity, or how to randomly demand human-only activity.
If your game is worth the attention, they will overcome you. They are many :)

How do you "Build" an exe that includes all the resource files like pics? Can exe be put on a web page?

I have students in high school who have created some programs using Visual Studio C#. They created some games and would like to now upload them to the web. I am pretty new to Visual Studio C#. I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on. It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place. How can I get a clean exe of their game? Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Microsoft wrote a guide on how to do exactly this. It's on their MSDN website, which is sort of like the developer back-bone for a lot of Microsoft software and documentation.
Old guide: Adding and Editing Resources (Visual C#)
Newer guide: How to: Add or Remove Resources
The gist is that the program needs to know where the files are, relative to the location of the compiled binary (in this case, an .EXE); There's several different ways to do this, depending on your level of expertise. I would suggest that you take a look at the guides above to start that journey.
there's a few ways of doing this. (Also, make sure you're creating a 'release' build when you compile).
You can include resources in your game by creating a resources file. This is something I usually do only on winforms applications etc.
If you have on-disk files you need to distribute those on-disk files along side your game. You could do this by zipping up your game.exe and the /files/images.img folder (or what ever your resources content folder is named).
If you're feeling adventurous you could create a 'deployment project' which is a project that allows you to create an installer file. This is a bit more work however you will have fine grained control over what files go where etc.
Good luck!
EXE files generally aren't self contained for video games with many resources, just add resources in an external folder and make sure the paths to the resources in their games are not absolute but relative in the local directory.
So for example:
get rid of paths like C:/Users/Bob/Desktop/Game/Images/player.png and replace with /Images/Player.png.
Also, an EXE generally doesn't run client side on webpages, it is possible but difficult. Things such as Flash are made for this sort of issue. I'd say make the webpage a place where they can download their games. Github has a nice way to do free websites called gh-pages. OFC, you could host one yourself but that would require a lot of setup work.
Like Monza said, you can zip up the files for download. Or, you could create an installer if you wanted to be really ambitious.
I thought after a program was "built" that you could go into the bin/debug folder and get the exe file for the program and be able to play the game without having to have Visual Studio on the actual computer you are playing it on.
That is correct, given that the other machine has the necessary .NET framework version installed AND any other resources like .dll files and config files are also present. When the application is ready for release, you can set the Build options in the project properties to Release, and then when you build all the files needed for distribution will be in the bin\Release folder.
It works with some of their games but some of them, there are graphical files that are missing in the exe file if all the other files aren't stored in the same place.
This may depend on how the application was written. If resources like pictures are embedded in the assembly then those files will not be needed to run on another machine. If the application is using hard coded paths for the image resources in the source code, then the application will likely break if the necessary files aren't present when the .exe is executed.
Can that exe be loaded up onto a web server so they can play it from there or at least download it from there?
Yes - you could upload the .exe to a file server to make available for a download, but you would not be able to run it within a browser over the web. I would recommend zipping up the .exe and other files needed and hosting the .zip file on the web server for download; browsers may give a warning or block downloading an .exe .
Hope this explains it a little bit for you.

Open Office assembly folder

I googled "Open Office C#" and found a commonly reoccurring tutorial: http://www.opendocument4all.com/download/OpenOffice.net.pdf
The trouble is this portion (snippet from pdf):
Change from the Visual Studio window to a Explorer window. Move to the
CLI assemblies folder. You will find them in your OpenOffice program
installation path in the folder named “assembly”. In this folder you
should see the following .net assemblies.
I do not have this "assembly" folder. I navigated to:
C:\Program Files (x86)\OpenOffice.org 3
It simply is not there. I have to create reports using C#.
As per comments above from the OP the goal is to create DOC or DOCX:
For creating DOCX there is a FREE option (OpenXML from MS) available...
For creating the older DOC format (among lots of other things there is for example Aspose.Words (commercial - just a happy customer, not affilliated).
EDIT - as per comment:
All above options work independently of Word (i.e. don't need Office present/installed on the machine).
I'm not sure Yahia understood what you were asking...
As, I had the same issue (I think), I thought I would share the solution I found:
In version(s) 3.x+ the cli_* dlls are placed in the GAC and (afak) inaccessible from a VisualStudio project. You have to extract them from the openofficeorg1.cab file (using RAR, WinZip, 7z, whatever).
Here is a link that goes into more detail covering the topic:
http://blog.nkadesign.com/2008/net-working-with-openoffice-3/
BTW, when I did this (successfully), I found 6 such cli_* dlls.
It's worth mentioning that when I came across this tidbit, I had already deleted the initial installation folder that was created during the setup, so I had to uninstal OpenOffice and then reinstall to get that folder back. After that it was easy.
Hope this was of some help.

Categories