Build native OpenSSL library for WP8 Platform - c#

I am creating Windows phone 8 application.I need to create App which uses compiled OpenSSL library.I was following standard latest library.
I am following INSTALL.W64 steps, as I don't know which INSTALL.* to be used.As my machine is 64 bit I preferred this:
To build for Win64/x64:
1 perl Configure VC-WIN64A
2 ms\do_win64a
3 nmake -f ms\ntdll.mak
4 cd out32dll
5 ..\ms\test
Using Visual Studio Command Prompt.Upto step 2 is fine.At 3rd step it fails to build and doesn't create library in out32dll Folder.It gives error like:
C:\Program Files (x86)\Windows Phone Kits\8.0\include\windows.h(182) : fatal err
or C1083: Cannot open include file: 'winreg.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
\VC\WPSDK\WP80\BIN\cl.EXE"' : return code '0x2'
Stop.
My question is :Is really OpenSSL supported for Windows Phone Platform.As I seen this which is true/false I am not sure.
Apart from this standard way I also tried this solution.Able to complete steps mentioned in answer.got build compiled in visual studio.Referenced OpenSSLWP8 in Windows Phone 8 Project.Compiled libeay32.
But when I try to create reference NativeCrypto nc = new NativeCrypto() I get FileNotFoundException in that library.Am I missing something?
Which solution is better or there is any other solution available so that I can build OpenSSL for WP8.
Any help is appreciated.
Thanks.

My question is: Is really OpenSSL supported for Windows Phone Platform. As I seen this which is true/false I am not sure.
Not officially.
I know one of the OpenSSL developers regularly build OpenSSL for Windows 8. I was also able to build for Windows 8. However...
I've got a bunch of patches for Windows RT and Windows Phone. The patches add three new targets, and it don't use VC-WIN64A. The added targets are VC-WP8-X86, VC-WP8-ARM, and VC-WINRT-ARM.
I added two new defines (OPENSSL_SYS_WINRT and OPENSSL_SYS_WINPHONE) so a lot of this went on:
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(OPENSSL_SYS_WINCE) &&
!defined(OPENSSL_SYS_WINRT) && !defined(OPENSSL_SYS_WINPHONE)
The cflags needed some tuning. For example, here's from Windows RT:
+ $base_cflags.= " /D WINAPI_FAMILY=WINAPI_PARTITION_APP";
+ $base_cflags.= " /FI SDKDDKVer.h /FI winapifamily.h";
And Windows Phone:
+ $base_cflags.= " /D WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP";
+ $base_cflags.= " /AI\"$ENV{'WINDOWSMETADATA'}\"";
+ $base_cflags.= " /FI SDKDDKVer.h /FI winapifamily.h";
The Windows RT target is severely crippled. As an example of how bad things are on Windows RT: the target needed both -DOPENSSL_NO_SOCK and -DOPENSSL_NO_DGRAM because applications are not allowed to access the socket API. That makes it pretty useless SSL library since TCP and UDP was gutted.
The Windows Phone target is a little better. Windows Phone allows access to the socket API (so TCP and UDP are available), but the random number generator seeding is broken. Its broken because Microsoft does not provide CryptGenRandom or the older Win32 screen APIs that were used to scrape state. Application will need to explicitly seed from RNGCryptoServiceProvider.
You can see traces of my suffering on Stack Overflow. For example, Windows RT: where is sockaddr_in?.

Related

C# LSP autocompletion client for neovim / vim8

I've tried several ways to make it work but there seems to be no easy way. Yes, there are a ton of plugins, configurations. But they do not work right as per Oct 2019.
OmniSharp-Vim client needs configuration, it covers only C# and it lists plugins integration that does not work anymore (try choosing it for linting in ALE).
YouCompeleteMe should work but it is large and seems bloated.
Deoplete don't have source for C# and configurations I found are out of date.
Coc.nvim does not even list C# and 'unofficial' configurations have issues (like this). Besides Coc.nvim seems to be an alien from VS Code.
LanguageClient-neovim I didn't find sensible configuration and it seems because C# LSP server needs .sln file.
So this seems that csharpers should go to VS (or Rider) and that is when MS proposed LSP. How do you make IDE like from nvim to work with C#?
Basically the client should start server like this and use LSP.
~/.cache/omnisharp-vim/omnisharp-roslyn/run -s <PATH TO SLN OR DIR>
I just got omnisharp / ale working successfully with a clean install. You may want to completely uninstall omnisharp (~\AppData\Local\omnisharp-vim or ~/.omnisharp) just in case you have old versions.
You didn't mention your OS; I have this working in both Windows 10 and Mac OS. If you're using Mac OS make sure you brew install libuv first.
My Environment
Windows 10 (v1903) and Mac OS 10.14.6
Vim 8.1.2244
dotnet core 3.1 - I'd expect 3.0 to work as well
Instructions
First off, I'm using vim-plug as my plugin manager to handle installation. I installed it in both Windows and Mac OS using the bash/powershell snippets in vim-plug's README.
Then I added the following to my vimrc (~\_vimrc on Windows, ~/.vimrc on Mac OS):
"vim-plug config
call plug#begin()
Plug 'OmniSharp/omnisharp-vim'
Plug 'dense-analysis/ale'
call plug#end()
" plugin config
let g:OmniSharp_server_stdio = 1
Restart vim, and run :PlugInstall. It will clone omnisharp and ale for you.
Next, find some C# solution, and ensure the solution builds at the commandline (e.g. dotnet build should complete without errors). You also need a SLN file if you don't already have one (dotnet new sln and then dotnet sln add MyProj.csproj)
Choose a C# file and open it in vim. You should see the following notification:
If the install doesn't autostart, you can start it with :OmniSharpInstall. The install takes a minute or two of downloading in a terminal window. After the installation is complete, reopen vim and execute :cd \path\to\my\solution to ensure the working directory inside vim is correct. Then open a file with e.g. :e MyProj\Program.cs.
The server will be started automatically; don't manually start it. I get a lot of syntax errors for the first few seconds while the server is starting, after that I don't have any errors.
To pull up the autocomplete, type something like Console. then hit Ctrl-x o:
The above screenshot has vim-airline for the bottom bar -- that's not part of omnisharp and isn't required.
The above screenshots are Windows, but it's also working fine in Mac OS:
My full vimrc is available here and the source code I'm testing with is available here.
So far here is my setting for this using Deoplete, OmniSharp and ALE (full config at https://github.com/artkpv/dotfiles/blob/master/.config/nvim/vimrc) :
" Install Deoplete and OmniSharp:
" - OmniSharp/omnisharp-vim " for LSP support (like start OmniSharp server) and code actions, etc
" - Shougo/deoplete.nvim " for better autocompletion
" - dense-analysis/ale " for highlights
function SetCSSettings()
" Use deoplete.
call deoplete#enable()
" Use smartcase.
call deoplete#custom#option('smart_case', v:true)
" Use OmniSharp-vim omnifunc
call deoplete#custom#source('omni', 'functions', { 'cs': 'OmniSharp#Complete' })
" Set how Deoplete filters omnifunc output.
call deoplete#custom#var('omni', 'input_patterns', {
\ 'cs': '[^. *\t]\.\w*',
\})
" ... then goes your mappings for :OmniSharp* functions, see its doc
endfunction
augroup csharp_commands
autocmd!
" Use smartcase.
" call deoplete#custom#option('smart_case', v:true)
autocmd FileType cs call SetCSSettings()
augroup END

Make changes to registry before installation of a program

Ok, I created an installation file for my program with InstallShield(software). I was not able to successfully install the program until I made changes to the registry as described here .NET 4 fails to install because SECUREREPAIR fails to CreateContentHash of file SetupResources.dll: for computing hash Error: 997. After making the changes to the registry, I am able to install my program. So, the registry changes are to be made before running my installer file. Can I not embed that .reg file somewhere from the InstallShield while creating the installer file so that the .reg file runs before my actual installation begins?
You can create a custom action in a script to update the registry and add to the sequence. Below is a rough example (won't work off without some tweaking).
Then add to your sequence before ISInstallPrerquisites in the UI Sequence.
STRING svCmd;
STRING svCmdPath;
begin
'For DWORD:
svCmd = "reg add " + KeyName + " /v " + ValueName + " /t REG_DWORD /d " + dataValue + " /f";
'For String:
svCmd = "reg add " + KeyName + " /v " + ValueName + " /t REG_SZ /d " + dataValue + " /f";
svCmdPath = "cmd";
LaunchAppAndWait(svCmdPath, "/c \"" + svCmd +"\"", LAAW_OPTION_HIDDEN | LAAW_OPTION_WAIT);
Does this problem occur on all computers, or just some? What OS?
What is your anti-virus softare, security suite?
Are you on a locked-down corporate SOE? (Standard Operating Environment).
Are there custom policies?
Are you using mandatory (or temporary) profiles?
Pre-Requisite: If this is the official Microsoft .NET 4 runtime installer which falls over, then I would exclude it from my own setup and deliver it as a pre-requisite alongside my main installer, or I would simply point to the web-page to download the latest version of that runtime. I much prefer the latter option since what you deliver with your package could be outdated in no time as new security hotfixes become available. Crucially: most people will probably have this runtime installed by now?
Windows Update: I might even tell the user to install via Windows Update, but that is more of a manual process with more steps. Isn't .NET 4 a mandatory Windows Update install by now?
Corporate Users: Corporate packagers will appreciate the separation of runtimes from your own package seeing as much time is spent taking pre-requisite packages out of vendor packages. They simply need some one-page documentation telling them what runtime is needed. They will have the right one pre-packaged according to their own corporate standard - and debugged of issues like you mention. There is not much need to combat the runtime setup.
Real World: You can deliver a *.reg file along with your .NET 4 installer file with a brief README.txt describing the problem you mention. Then they can deal with it if they have to, and if the problem is not seen then you avoid all the fuss. Then you add a LaunchCondition to your main setup to prevent its installation unless .NET 4 is installed.
Installer softwares usually (always ? Well instalShield has one at least) have a "Registry" feature where you can define the registry hierarchy/entries/values you wanna add.
No need of any script or reg file. All values are set up before the installation they are linked with.
Anyway, you are unlikely asked to find a work around as InstallShield already deal with it for you. Just set it up in the installer.

Is it possible to run Kinect V2 inside a Docker container?

I'm exploring the feasibility of running a C# Kinect Visual Gesture Program (something like Continuous Gesture Basics project https://github.com/angelaHillier/ContinuousGestureBasics-WPF) inside of a Docker for Windows container.
Is this even theoretically possible (run C# Kinect in a Docker for Windows container?)
If the answer to 1 is yes, here are some extra details:
I'm using the microsoft/dotnet-framework:4.7 image as a basis and my initial Dockerfile looks like this:
FROM microsoft/dotnet-framework:4.7
ADD . /home/gesture
WORKDIR /home/gesture
Build the image:
$ docker build -t kinect .
Turn on container:
$ docker run -dit --name kinectContainer kinect
Attach to a powershell session to monkey around:
$ docker exec -it kinectContainer powershell
When I attempt to run my gesture application from the Docker container I get the following error (which is expected since no Kinect SDK was installed in the container):
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058) ---> System.BadImageFormatExcep
tion: Cannot load a reference assembly for execution. erable program. Check the spelling of the name, or if a path was included, verify that the path
--- End of inner exception stack trace ---
at GestureDetector.GestureDetectorApp..ctor()
At this point, the big question is how to install the Kinect v2 SDK [KinectSDK-v2.0_1409-Setup.exe] or the Kinect v2 runtime [KinectRuntime-v2.0_1409-Setup.exe] in the container.
The installers have a EULA and according to some clever University of Wisconsin folks, there is a technique to to extract installers using Wix's dark.exe decompiler(https://social.msdn.microsoft.com/Forums/en-US/a5b04520-e437-48e3-ba22-e2cdb46b4d62/silent-install-installation-instructions?forum=kinectsdk)
ex.
$ & 'C:\Program Files (x86)\WiX Toolset v3.11\bin\dark.exe' C:\installerwork\KinectRuntime-v2.0_1409-Setup.exe -x c:\installerwork\kinect_sdk_installersfiles
The issue I ran into when I got to the underlying msi files is there is no option to run them silently using msiexec.
I've figured out that the runtime installer (Runtime installer (KinectRuntime-x64.msi) extracted from the Kinect v2 SDK) makes at least the following changes in the filesystem:
Creates a folder "Kinect" in C:\Windows\System32 and adds 3 files to System 32:
k4wcll.dll
kinect20.dll
microsoft._kinect.dll
The last three files in System32 should be the 64-bit versions (the installer appears to have x86 and x64 versions of those 3)
Replicating those changes by hand does not lead to success on the host machine let alone in the container.
It's currently unclear what other registry/system changes are occurring with the installer (and whether or not that would get us over the goal line in the Docker container)
Any ideas about how to proceed from here?
In short no. docker on windows does not have the ability to hardware tunnel/map. on Linux, it does via the --device= option
As #VonC has stated you will need to use a Windows VM this could be Hyper-V or you can use Virtual Box then you can provide the Kinect Hardware via the Tunneling method (add/connect device), without this there would be no way for your container be that VM or not to access the hardware of the host machine with windows.
Another approach would be to try and install Kinetic in a Windows server VM, and detect the exact changes brought by said installation.
See for instance "How can I find out what modifications a program’s installer makes?" and a tool like ZSoft Uninstaller 2.5.
Once you have determined exactly what files/registry/variables are impacted by the installation process, you can replicate that in a Dockerfile.

Failed to add a WMAsfReader into the FilterGraph

Add a WMAsfReader caused Error,HRESULT was -2147024770.The code is as follow:
sourceFilter = (IBaseFilter) new WMAsfReader();
((IFileSourceFilter)sourceFilter).Load(fileSource, null);
hr = filterGraph.AddFilter(sourceFilter, "WM ASF Reader");
MessageBox.Show(hr.ToString());
When I run this code on Win10 with WMP,it works well;but it does not work on Win7 without WMP.But I can find the "WM Asf Reader" in the registry,qasf.dll as well.What is the problem?Thanks.
Error Image:
The error code -2147024770 is 0x8007007E ERROR_MOD_NOT_FOUND "The specified module could not be found."
Such error for a Windows core component might indicate that something is broken in your Windows (e.g. certain application installed and registered the same DLL and then it was deinstalled - resulting in broken registration of the original module). It might also be caused by Windows 7 N version having no Windows Media in the default configuration, you are supposed to add the feature by installing a Feature Pack.
but it does not work on Win7 without WMP...
...The Media Feature Pack for Windows 7 N or Windows 7 KN will install Media Player and related technologies on a computer running...
It is not only Windows Media Player missing in N editions, but also the underlying APIs, used by WM ASF Reader.

Can't load AMD 64-bit .dll on IA 32-bit platform

All.
There is an error that I met when I try the first "hello world" Android App with VisualStudio Community 2017 , I can't open the Main.xaml file within Vs 2017. And I try to find solution from stackoverflow.com, yes, there are some question like "Can't load AMD 64-bit .dll on IA 32-bit platform", but what I met is a little different. So what can I do?
More information:
1. OS in my laptop is 32-bit Win7;
2. There are someting wrong during the installation of "Mobile Development With .net", and there is the unique module I have installed with VS 2017.
can not download “AndroidNDK_R13B,version=13.1.5,chip=x86” from “https: //go.microsoft.com/fwlink/?linkid=833503”;
can not download “https: //go.microsoft.com/fwlink/?linkid=841570” from “AndroidEmulator_API23V2,version=1.0.28” ;
3. The detailed information about the exception is: (When I double clicked on the Main.Xaml file)
er
ava.lang.UnsatisfiedLinkError: C:\Users\Hargendas\AppData\Local\Temp\AndroidDesigner3976194309885156563.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at mono.android.JniHelper.loadEmbeddedJniLibrary(JniHelper.java:28)
at mono.android.D3DImageFactory.<clinit>(D3DImageFactory.java:14)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at mono.android.DesignerSession.initializePlatformSpecific(DesignerSession.java:86)
at mono.android.DesignerSession.<init>(DesignerSession.java:75)
at mono.android.Project.createSession(Project.java:382)
at mono.android.Project.processMessage(Project.java:414)
at mono.android.MessageListener.executeMessage(MessageListener.java:88)
at mono.android.MessageListener$Runner.run(MessageListener.java:44)
at java.lang.Thread.run(Thread.java:748)
I have move the "C:\Program Files\Android" folder to "D:\Program Files\Android" and "C:\ProgramData\Microsoft\VisualStudio\packages" to "D:\Program Files\VS2017SDK", and build symbol link with these folder by the "mklink" operation.
Is it any effect with the error? And where did the temporary "AndroedDesigner3976194309885156563.dll" made from? and everytime I try to open the Main.xaml, the temporary file with error is different, How to solve the problem?
I had try to install a 64-bit JRE, but my OS is 32-bit, it would not be installed successfully. So Do I have to upgrade My laptop to 64-bit Win10?
Thanks.
Try installing JDK then launch VS and go to
Tools -> Xamarin -> Android Settings and under "Java Development Kit Location" press change and select ProgramFiles/Java/jdk1.8.0_131 instead of ProgramFiles(x86)/Java/jdk1.8.0_131
I dont know if it will work for everyone, i am not very experienced but it worked for me

Categories

Resources