Having Issues With EV Code Signing - windows

I have recently purchased EV Code signing certificate from DigiCert...
Now i am having issues to sign my installer executable files.
Currently (Till now) below is the process to make the installer:
Step-1:
My installer is configured in a way so, it will load all common files from it's child support directory.
like below files structure:
Setup.exe (it's only have application exe file and few other configuration file that changes time to time)
Support (Directory)
Support\DLL (Has DLL files that is required by my application)
Support\Others (Any Other files)
Support\ETC (Just for example purpose)
All those support files is resided on my server as they don't change frequently
so, i have created a wrapper installer.exe file and a script to handle the wrapper..
That wrapper installer.exe file also resides on my server
Step-2:
My script does below steps:
a) make the setup.exe with the updated application files.
b) upload setup.exe file to server
c) add (append) that setup.exe and all others required files at the end of wrapper installer.exe file
d) I Provide That wrapper installer.exe (single file) to my clients/users.
Step-3:
When that wrapper executes, it creates a temp folder in temp directory. extract all the files that is appended in itself. and run the setup.exe from that temp directory
I make this process, as i only have to change application file that is few kilobytes only (always below 1mb), but those support files are huge in size.
So, instead of having to upload all those files from my local computer each time.
i make this wrapper process to make update/upload process much faster.
Now, The Problem:
If i sign the wrapper.exe file and put it to server, but when my script append data to that file, it looses the certificate settings (it's no longer signed :( )
so, how can i overcome this situation..
Update-1:
As asked, below is the php code that used to append setup.exe file:
//Appending Setup.exe file...
$archive_File = 'files/' . $strFileID . '.exe';
if (is_file($archive_File) == 1)
{
$strSize = filesize($archive_File);
$strData = 'Setup.exe' . chr(0) . $strSize . chr(0) . file_get_contents($archive_File) ;
file_put_contents($strArchiveFile, $strData, FILE_APPEND | LOCK_EX);
}
else
{
exit ('following file does not exits: ' . $archive_File);
}
best regards

You can't modify wrapper.exe after you've code signed it. That's the whole point of code-signing - to validate that a virus or other tampering didn't occur on the signed executable.
I'm not sure why you are code signing wrapper.exe first, then appending the files to it afterwards. You need to do the following steps:
Code sign setup.exe and all other binaries first except for wrapper.exe
Append setup.exe and all other files to wrapper.exe.
Then code-sign wrapper.exe after it's been fully built.
There are a lot of free tools that will generate a self-extracting archive that when run will prompt the user to run the setup.exe within it. 7Zip will do this for free.
But it sounds like you need to build your wrapper.exe on demand right before it's downloaded. If that's the case, add the code signing script to your server code that builds the final wrapper.exe

Related

How do I create or modify a VB6 exe Version resource block to make it Squirrel-Aware

I have this crazy idea to take a large VB6 app we are continually migrating to .NET and use the Squirrel for Windows installer. It seems I need to make the VB6 app Squirrel-Aware as described here -- add VALUE "SquirrelAwareVersion", "1" to the Version resource block.
The problem is I'm very unfamiliar with rc files and there are only bits of documentation on the format, encodings, etc especially when working with VB6. I think I need a command line tool that can add this VALUE "SquirrelAwareVersion", "1" to the Version resource of an existing exe, OR figure out how to get VB6 to use a custom .res file with all the version data in it.
Most tools only seem to modify basic resource info like icons, manifests, and strings. I would need something capable of modifying or replacing this version data.
I've attempted to create a basic .rc. I make an empty file with the name MyApp.rc. Open the file with Visual Studio. Add a "Version" resource and attempt to compile it to .res with RC.exe but I get all sorts of errors from this file generated by Visual Studio. If I close and reopen the generated RC file, even Visual Studio can't open it. Could be an encoding problem? I'm not sure how else to create a valid RC file.
You can use Resource Hacker utility in CLI mode to replace whatever resources you need to in your final executable. It can even compile .rc files to .res file with something like this:
c:> ResourceHacker.exe -open Project1.rc -save Project1.res -action compile
Then use something like this on the command line to add new or replace existing resources from a .res file into your final executable:
c:> ResourceHacker.exe -open Project1.exe -save Project1.exe -action addoverwrite -resource Project1.res
Add -log NUL parameter to suppress console output if you need to.
Make a res file in VB6. VB6 only allows editing of certain things. Use ResHacker to add anything else you want to the Res file. VB6 add it's own version so you may need to do it to the exe file. http://www.angusj.com/resourcehacker/

How to package a Kivy app with Pyinstaller

I have a lot of troubles following the instructions form the Kivy website, many steps aren't explained like what should I answer to the warning.
WARNING: The output directory "..." and ALL ITS CONTENTS will be REMOVED! Continue? (y/n)
Even if I choose y, the folder isn't removed.
Also should I always add these lines:
from kivy.deps import sdl2, glew
Tree('C:\\Users\\<username>\\Desktop\\MyApp\\'),
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)]
in the .spec file? Why are they necessary?
Not many info is available for Kivy.
Because I spent a lot of time understanding how I should package my app, here are some instructions that would have really helped me.
Some info are available at http://pythonhosted.org/PyInstaller/
Python 3.6 as of march 2017
Because packaging my app gave me the error IndexError: tuple index out of range, I had to install the developement version of PyInstaller:
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
Step 1:
I moved all the files of MyApp in a folder "C:\Users\<username>\Desktop\MyApp": the .py, the .kv and the images and I created an icon.ico.
I created another folder C:\Users\<username>\Desktop\MyPackagedApp. In this folder I press Shift+right click and select open command window here.
Then I pasted this:
python -m PyInstaller --name MyApp --icon "C:\Users\<username>\Desktop\MyApp\icon.ico" "C:\Users\<username>\Desktop\MyApp\myapp.py"
This creates two folders, build and dist, and a .spec file. In dist/MyApp, I can find a .exe. Apparently, if my app is really simple (just one label), the packaged app can works without the Step 2.
Step 2:
The second step involves editing the .spec file. Here is an exemple of mine.
(cf Step 3, for the explanations about my_hidden_modules)
I go back to the cmd, and enter
python -m MyApp myapp.spec
I then got this warning:
WARNING: The output directory "..." and ALL ITS CONTENTS will be REMOVED! Continue? (y/n)
I enter y and then press enter.
Because I choosed y, I was surpised that the folder build was still there and that the dist/MyApp was still containing many files. But this is normal. PyInstaller can output a single file .exe or a single folder which contains all the script’s dependencies and an executable file. But the default output is a single folder with multiple files.
Step 3: adding hidden modules
When I click on the myapp.exe in dist/MyApp, the app crashed. In the log C:\Users\.kivy\logs\ I could find 2 errors: ModuleNotFoundError: No module named 'win32timezone' and SystemError: <class '_frozen_importlib._ModuleLockManager'>.
Because of this I had to edit the .spec file and add these lines:
my_hidden_modules = [
( 'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages\\win32\\lib\\win32timezone.py', '.' )
]
in a = Analysis I changed datas = [] to datas = my_hidden_modules,
Apparently this is because I used a FileChooser widget.
So, the line:
ALL ITS CONTENTS will be REMOVED!
yes, it will be removed AND replaced later with new files. Check the date. I think it prints permission denied if it can't do such a thin both for files and the whole folder, so you'd notice it. It's important though, because you need to add additional files into your folder.
Those additional files of two types:
kivy dependencies
application data
Dependencies are just binaries (+/- loaders, licenses, or so), you get them through the *[Tree(p) ...] piece of code, which is just a command for "get all files from that folder". Without them Kivy won't even start.
Similarly to that, the second Tree(<app folder>) does the same, but for your own files such as .py files, .kv files, images, music, databases, basically whatever you create.
Obviously if you remove the deps, app won't start and if you remove app data, you'll get some path errors and most likely crash. You don't want any of that :P
It also works if in the 'a = Analysis...' block in the spec file one substitutes
hiddenimports=[]
for
hiddenimports=['win32file', 'win32timezone']
for win32file, win32timezone or for whatever files are missing

Where does Steam store library directories?

In Steam, we can configure multiple directories/folders where it will look for applications. It is found in the menu Steam->Settings->Downloads->STEAM LIBRARY FOLDERS dialog.
Where can I find those settings if I'm looking programatically from outside Steam?
I'm more interested in the location for the Windows client.
Found it. On Windows they are stored in C:\Program Files (x86)\Steam\SteamApps\libraryfolders.vdf, and you also have to add Steam's install folder C:\Program Files (x86)\Steam
Here's a sample Python script to extract the information:
import re
with open(r"C:\Program Files (x86)\Steam\SteamApps\libraryfolders.vdf") as f:
folders = [r"C:\Program Files (x86)\Steam"]
lf = f.read()
folders.extend([fn.replace("\\\\", "\\") for fn in
re.findall('^\s*"\d*"\s*"([^"]*)"', lf, re.MULTILINE)])
I found it here:
C:\Program Files (x86)\Steam\config\config.vdf
There's a line in that file:
"BaseInstallFolder_1" "{YourSteamLibraryFolder}"
So I just open it with Notepad then Ctrl+F search 'Base'.
If that line is not in there:
Open Steam. > Sign into you account. > 'Steam'. > 'Settings'.
Then click on 'Downloads'. > 'STEAM LIBRARY FOLDERS'.
Make an empty folder somewhere.
Click on 'ADD LIBRARY FOLDER'.
Browse to the empty folder you made. > Click on 'SELECT'.
If you then look at the config.vdf again; there should be a line like this:
"BaseInstallFolder_1" "{YourNewEmptySteamLibraryFolder}"
If Steam hasn't been installed in the default location in Windows, you can find it in the registry under HKEY_LOCAL_MACHINE, on path SOFTWARE\Wow6432Node\Valve\Steam. Here's how I found it in Kotlin:
private val steamFolder: File = File(WinRegistry.getString(
WinRegistry.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Wow6432Node\\Valve\\Steam",
"InstallPath"))
You can then find the libraryfolders.vdf and config.vdf files, as per the other answers.
In each of those library folders you'll find files called appmanifest_<id>.acf, where <id> is the id of the game (find it in Properties / Updates on Steam). If you're looking for a particular game, that will help to determine which folder the game is in, if there's more than one game install location.

How to get a .exe packaged Ruby Shoes app to reference resources outside the package?

I'm trying to make a standalone .exe packaged Ruby Shoes app that uses images dynamically, meaning whichever images is found in the folder of the .exe file.
Shoes.app() {
background "bg.jpg"
}
This code works if the image is in the same folder when the .exe is packaged, and the image seems to be packaged into the .exe since it's not needed in the same folder as the .exe for it to display when running the exe. But when you want it to load the file in the same folder as the .exe, packaging the app without the image, it does not show. I've tried different ways at finding absolute path to the current directory where the .exe is launched from, but they all seem to point to some temporary directory under AppData and not where the .exe file is located.
Edit: my first answer was incomplete. Windows is a little odd in Shoes for packaged apps. Write a little test script.
Shoes.app do
stack do
para "DIR: #{DIR}"
para "LIB_DIR: #{LIB_DIR}"
cdir = Dir.getwd
para "CWD: #{cdir}"
end
end
Dir.getwd is probably what you want.
Calling pwd should get you what you want
Nope, Ok sorry get it now !:-)
Shoes is opening your exe/shy into AppData/temp so working directory and __FILE__ both point there !
Someone, some time ago proposed this : Trying to access the "current dir" in a packaged Shoes app
must be a better way !
EDIT:
you probably want custom packager (check "i want advanced install options")
check "Expand shy in users directory"
Do as you done for regular packaging.
Now when launching the exe, it will ask you( or the user) to choose where to install your app, proceed, note the directory.
Now before launching the installed app feed the noted directory with your resources and you should be ok
Some references : https://github.com/Shoes3/shoes3/wiki/Custom-Install-Scripts
(there's a lot more to it)
https://github.com/Shoes3/shoes3/issues/247#issuecomment-213919829

Deploying custom resource through DSC PullServer fails to extract the module

I've set up a DSC PullServer on Server 2008 R2 and I've run into an issue deploying a custom module. The module on the PullServer is in C:\Program Files\WindowsPowerShell\Modules\NTFSPermission, I've zipped everything using Windows Explorer (and 7-zip) and placed the zip in C:\Program Files\WindowsPowerShell\DscService\Modules\NTFSPermission_1.0.zip, I create a checksum using NEW-DSCChecksum for the zip file and I've got Import-DSCResource NTFSPermission in my node configuration. When I run the Invoke-CimMethod to push the config to a node it errors out with:
Invoke-CimMethod : Failed to extract the module from zip file
C:\Windows\TEMP\\635291179507191263\NTFSPermission_1.0.zip downloaded by Download
Manager WebDownloadManager.
The node logs a 4104 error in the event viewer reading:
This event indicates that failure happens when LCM is trying to get the configuration from pull server using download manager WebDownloadManager. ErrorId is 0x1. ErrorDetail is Failed to extract the module from zip file C:\Windows\TEMP\\635291179507191263\NTFSPermission_1.0.zip downloaded by Download Manager WebDownloadManager.
Has anyone else run into this? I'm not sure if there's a config file somewhere that is literally piping in an extra backslash and causing an invalid download/extraction path or if there is something wrong with the zipped module. If I move the module over manually the config will be pushed and apply successfully, which leads me to believe it's not the module.
There is a known issue with extracting zip files created using .NET compression class in 4.5. The workaround is to use the shell method of compressing files. That is, send to compressed archive option in right-click context menu or using Shell COM object.
I tested one of the modules from the DSC Resource Kit and it extracted with no problems on the desired node. I tracked the problem down to the psd file that the author created for their DSC-Resource. I updated the CLRVersion to require 4.0 and removed RequiredModules, RequiredAssemblies, ScriptsToProcess, TypesToProcess,FormatsToProcess and NestedModules (all were empty values anyway), pushed the config without the workaround and it downloaded and extracted the resource.

Resources