How to open 7z self extracting .exe file programmatically in c#? - c#

I want to open the .exe file in button click. Using ZipFile.ExtractDirectory not working for .exe file and it throws exception.
Can anyone help me how to overcome this?

Please, consider using the LZMA SDK from 7-Zip link it contains the binaries, libraries and code examples on how to use properly the sdk with C# and other langs, it's like if you are using your owm 7-zip archiver. But only using all of you need.
Or, things more easier... link
Contains built-in compression/descompression modules only for implement in your solution.
Last thing, use the CLI of 7-Zip.
PD: Remember the UnauthorizedAccessException is due the Windows permission to your app, make sure you are reading/writting in a reachable directory, even you can add Admin Privilegies to your app. Hope this help you. Have a Nice Day! :)

Related

How to transfer C# Windows form (.NET Framework) from one PC to another PC

As you could guess, I'm an absolute beginner to Visual Studios and C# Windows Forms (.NET Framework). I want to transfer my project from my laptop to my PC but I have no idea how to do so. I've been trying for quite a while but can't seem to get what files to copy. I'm copying the [Name].cs , [Name].Designer.cs and [Name].resx files but I can't seem to get them to work. should I copy the whole folder or .sln file or what?
Could anyone help me please?
Copy the whole root directory where the .sln is or .csproj if it is a single winforms project.
On the destination computer you might need some prerequisites.
If you want to be able to work on it and update it from both places, use GitHub and make a private repository. That's an easy way. The other way is follow the file path: C:\users\admin\source\repos and find your project in that list of folders. You could copy it to a flash drive, if you wanted to do it that way.

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 :)

GAC_MSIL and Shell Extensions

I've trying to develop while also creating a COM .DLL for my shell icon overlay and context stuff, so i do some search on the tool to make this happens, then i found SharpShell, the shell extension helper tool.
I've been using sharpshell to create an example .DLL, once its generated, i used their "Server Manager" to automatically helps register my .DLL to the registry and the server is loaded properly.
On the Registry, I've seen them registered properly, but i don't see any change in my UI. So i tried to download "Shell Ext Viewer - Shexview - 64 Bit. "
After i opened my shell lists, i saw my Dll was registered there, but they are reading my .DLL files in C:\Windows\Assembly\GAC_MSIL\ folder.
So i tried browsing them in in my Explorer, but i find out that i dont have GAC Assembly.
I further checked articles for help, i found out that they're .nEt extensions, and i also checked my .NET, all of the .NETs from 4.0 are installed properly, but i dont have GAC_MSIL in my assembly. What should i do in order to tell my Shell to open my dll file into a correct file? is there any a way from visual studio where can i register my Dll and server to a specified folder, instead of GAC_MSIL folder, because i am missing it?
Thank you, and i would really appreciate your help !
There are some limitations for OverlayIcons. You have only 15 slots for OverlayIcons. If you have Dropbox or Google Drive installed (or Subversion) > you have already lost, because no slots are available anymore.
But there some way to make bigger Priority for your ShellExtensions. Read here more https://github.com/dwmkerr/sharpshell/issues/93

CookComputing.XmlRpcV2.dll Direct download?

I started using a 3rd party API that depends on XML-RPC.NET using CookComputing.XmlRpc; I can download the source files but there is not an actual "XmlRpcV2.dll" file anywhere in the zip.
It looks like you are supposed to build it, but when I open the src project in MS Visual C# EXPRESS and do the conversion wizard, then try to build it I am getting 842 build errors about not being able to find types or namespaces for the following: NUnit, TestFixture, TextFixtureAttribute, Test, etc ...
Does anyone know where I can download the "XmlRpcV2.dll" file so that I can simply drop it into my C# project and start using it? I can't seem to find a direct download of the compiled dll anywhere online. Is it perhaps used in other downloadable projects somewhere?
I downloaded version 2.5.0
Any help appreciated.
This is a problem if you're using Windows Explorer to unzip the distribution file (Explorer hides the dlls). The zip file structure will be changed in version 3.0 onwards to avoid prevent this from happening.
Perhaps the best way these days to add XML-RPC.NET to a project is to use NuGet.
Open the bin directory in the download - you should see CookComputing.XmlRpcV2.dll. This is what you want.
I assume you obtained the download from here: http://www.xml-rpc.net/download.html

Access SDExplorer (System Folder) from my C# app

I am trying out Windows Live SkyDrive, and I installed SDExplorer (http://www.cloudstorageexplorer.com/)
It works by adding my SkyDrive folder to Windows Explorer, but it does not get a drive name or anything, so how can I access that drive/folder from my C# application?
When I go into the folder and look at the address bar it says "Computer\SDExplorer".
Directory.GetDirectories(#"\Computer\SDExplorer") does not work, because it translates to "C:\Computer\SDExplorer".
I would like to be able to create a small application that can create folders and upload files to my SkyDrive account.
Anybody know how these special folder/drives work? - I noticed MozyHome appears in the same way in my Windows Explorer.
Some background info: http://www.technospot.net/blogs/how-to-create-a-system-folder-in-my-computer/
The SDExplorer folder is a system folder. You can find it in the registry at the following location
HKEY_CLASSES_ROOT\CLSID{0016CE0E-728C-4FC9-98E5-D0B35B384597}
Instead of using shell32.dll it uses C:\Program Files\SDExplorer\SDShellNSE.dll,0 with the parameter a0800018 instead of a normal path.
If my assumptions are correct, the folder location is hidden somewhere in that DLL file. I had a look with a hex editor but could not find anything useful.
Thanks a lot for your replies. Because I am interested in how this works I will try to dig a little deeper. Thanks for pointing me in the right direction.
I have managed to build my small application (made it into a service), which can create folders and upload files to SkyDrive. I did this without SDExplorer, and instead I used the SkyDrive .NET API someone build here: http://skydriveapiclient.codeplex.com/
Greetings
Søren

Categories