NSP(Winsock命名空间服务提供商)和Metro Style应用程序 [英] NSP (Winsock Namespace Service Providers) and Metro Style apps

查看:195
本文介绍了NSP(Winsock命名空间服务提供商)和Metro Style应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对NSP(Winsock命名空间服务提供商)有疑问。


它们是否可以在Metro App中使用?


如果不是,那是什么它们的迁移路径?


如果我需要打开一个新线程,请告诉我。


   


根据我们的测试,命名空间提供程序(NSP)在Win8 build 9200 x64中对Metro应用程序无法正常工作。


我在VS 2012中创建了测试程序,并在调试器下运行它们以检查MyNSP.dll是否加载。


 


如果我使用WSCInstallNameSpace()为名称空间NS_DNS(12)安装NSP,它会正常加载到平时桌面应用程序。


以下是调用gethostbyname(" microsoft.com")时发生的情况:


"DesktopApp.exe"(Win32):已加载"C:\ Windows \ System32 \NapiNSP.dll"。


'DesktopApp.exe'(Win32):已加载'C:\ Windows \ System32 \ msvcrt.dll'。


'DesktopApp.exe'(Win32):已加载'C:\ Windows \ System32 \\ \\ sechost.dll'。


'DesktopApp.exe'(Win32):已加载'C:\ Windows \ System32 \ pnrpnsp.dll'。


'DesktopApp.exe'(Win32):已加载'C:\ Windows \ System32 \ nlaapi.dll'。


'DesktopApp.exe'(Win32):已加载'C:\ Windows \\ \\ System32 \mswsock.dll'。


'DesktopApp.exe'(Win32):已加载'C:\ Windows \ System32 \dnsapi.dll'。


'DesktopApp.exe'(Win32):已加载'C:\ Windows \ System32 \ winrnr.dll'。


'DesktopApp.exe'(Win32):已加载'C:\\ \\视窗\\ System32 \ MyNSP.dll'。


 


如果我在Metro应用程序中调用类似的内容:


StreamSocket ^ clientSocket = ref new StreamSocket();


clientSocket-> ConnectAsync(ref new HostName(L" microsoft.com"),L" http" ;);


我看到以下内容:


"MetroApp.exe"(Win32):已加载"C:\ Windows \ System32 \ Windows.Networking.dll"。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ Windows.Networking.Connectivity.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ FirewallAPI.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ws2_32.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ nsi.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ mswsock.dll'。


...


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ NapiNSP.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ pnrpnsp.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ nlaapi.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ winrnr.dll'。


未加载MyNSP.dll,但已成功加载来自Microsoft的其他NSP,如NapiNSP.dll,winrnr.dll等。


 


如果我将MyNSP的命名空间从NS_DNS(12)更改为其他任何内容,例如NS_TCPIP_LOCAL(10),Metro应用程序开始正确加载:


'MetroApp.exe'(Win32):已加载'C :\ Windows \ System32 \ MyNSP.dll'。


最后,如果我使用Metro版本的Internet Explorer或者内置Web Metro API,如MyWebView-> Source = ref new Uri(" http://microsoft.com");


我看到了这个:


'MetroApp.exe'(Win32):已加载'C:\ Windows \\ \\ System32 \ws2_32.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ nsi.dll'。


'MetroApp.exe'(Win32):已加载'C:\ Windows \ System32 \ winhttp.dll'。


'MetroApp.exe'(Win32):已加载'C:\\ \\ windows \ System32 \IPHLPAPI.DLL'。


'MetroApp.exe'(Win32):Loa ded'C:\ Windows \ System32 \ winnsi.dll'。


'MetroApp.exe'(Win32) :已加载'C:\ Windows \ System32 \ mswsock.dll'。


'MetroApp.exe'(Win32 ):已加载'C:\ Windows \ System32 \ dnsapi.dll'。


既不是MyNSP.dll也不是标准Microsoft NSP已加载。


 


现在,我们将尝试在Win8.1中再次进行测试。


 


如果NSP不再起作用我们应该使用什么呢?


也许你可以提出建议?


基本上我们需要捕获DNS请求并通过安全隧道将它们隧道传送到远程服务器。


NSP在这种情况下工作正常。


 


谢谢。

解决方案

我不熟悉Store app C ++,对于.NET,我们可以查看这个以解析主机名:  http://stackoverflow.com/questions/13489832/how-to-使用Windows.Networking获取ipaddress-from-hostname-in-c-sharp-windows-8-metro-app

; 
使用Windows.Networking.Sockets;

HostName serverHost = new HostName(" www.google.com");
StreamSocket clientSocket = new Windows.Networking.Sockets.StreamSocket();

//尝试连接到远程主机
await clientSocket.ConnectAsync(serverHost," http");

//现在尝试使用clientSocket.Information属性
// clientSocket.Information.RemoteAddress
//获取IP地址


I have a question about NSP (Winsock Namespace Service Providers).

Will they work in Metro App?

If no, what is the migration path for them?

Please let me know if I need to open a new thread.

  

According to our tests Namespace Providers (NSP) did not work properly for Metro apps in Win8 build 9200 x64.

I have created test programs in VS 2012 and run them under debugger to check whether MyNSP.dll loads or not.

 

If I install NSP for name space NS_DNS (12) with WSCInstallNameSpace() it loads properly into a usual desktop application.

Here is what happens when I call gethostbyname("microsoft.com"):

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\NapiNSP.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\pnrpnsp.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\nlaapi.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\mswsock.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\dnsapi.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\winrnr.dll'.

'DesktopApp.exe' (Win32): Loaded 'C:\Windows\System32\MyNSP.dll'.

 

If I call something like this in Metro app:

StreamSocket ^clientSocket = ref new StreamSocket();

clientSocket->ConnectAsync(ref new HostName(L"microsoft.com"), L"http");

I see the following:

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Networking.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Networking.Connectivity.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\FirewallAPI.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\nsi.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\mswsock.dll'.

...

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\NapiNSP.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\pnrpnsp.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\nlaapi.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\winrnr.dll'.

MyNSP.dll is not loaded but other NSPs from Microsoft like NapiNSP.dll, winrnr.dll, etc have been successfully loaded.

 

If I change namespace for MyNSP from NS_DNS (12) to anything else e.g. NS_TCPIP_LOCAL (10), Metro apps start to load it properly:

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\MyNSP.dll'.

Finally if I use Metro version of Internet Explorer or a build-in web Metro API like MyWebView->Source = ref new Uri("http://microsoft.com");

I see this:

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\nsi.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\winhttp.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\IPHLPAPI.DLL'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\winnsi.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\mswsock.dll'.

'MetroApp.exe' (Win32): Loaded 'C:\Windows\System32\dnsapi.dll'.

Neither MyNSP.dll nor standard Microsoft NSPs are loaded.

 

Now, we will try to do the test again in Win8.1.

 

If NSPs do not work anymore what should we use instead?

Maybe you can suggest something?

Basically we need to capture DNS requests and tunnel them through a secure tunnel to the remote server.

NSP worked just fine for this scenario.

 

Thank you.

解决方案

I'm not familiar with Store app C++, for .NET, we can check this for resolving a hostname: http://stackoverflow.com/questions/13489832/how-to-get-the-ipaddress-from-hostname-in-c-sharp-windows-8-metro-app

using Windows.Networking;
using Windows.Networking.Sockets;

HostName serverHost = new HostName("www.google.com");
StreamSocket clientSocket = new Windows.Networking.Sockets.StreamSocket();

// Try to connect to the remote host
await clientSocket.ConnectAsync(serverHost, "http");

// Now try the clientSocket.Information property
// e.g. clientSocket.Information.RemoteAddress
// to get the ip address


这篇关于NSP(Winsock命名空间服务提供商)和Metro Style应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆