mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-12 18:29:04 +00:00
Changed: Use wide versions of Win32 API
This commit is contained in:
parent
d5e75314f8
commit
1840d26972
6 changed files with 32 additions and 27 deletions
|
@ -385,7 +385,7 @@ bool CBGDownloaderAccess::CDownloadCoTask::isDownloaderProcessRunning()
|
||||||
{
|
{
|
||||||
// the downloader creates a system-wide mutex, so if present, assume that the downloader is running
|
// the downloader creates a system-wide mutex, so if present, assume that the downloader is running
|
||||||
//
|
//
|
||||||
HANDLE mutex = CreateMutex (NULL, FALSE, BGDownloader::DownloaderMutexName);
|
HANDLE mutex = CreateMutexW (NULL, FALSE, BGDownloader::DownloaderMutexName);
|
||||||
if (mutex)
|
if (mutex)
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
|
||||||
|
|
||||||
#define REGKEY_RYZOM_PATH "Software\\Nevrax\\ryzom"
|
#define REGKEY_RYZOM_PATH L"Software\\Nevrax\\ryzom"
|
||||||
#define REGKEY_PERMANENT_BAN "PB"
|
#define REGKEY_PERMANENT_BAN L"PB"
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************
|
// ************************************************************
|
||||||
|
@ -36,10 +36,11 @@ static void setPermanentBanRegistryKey(bool on)
|
||||||
nlinfo("Not implemented");
|
nlinfo("Not implemented");
|
||||||
#else
|
#else
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_RYZOM_PATH, &hKey)==ERROR_SUCCESS)
|
if (RegCreateKeyW(HKEY_CURRENT_USER, REGKEY_RYZOM_PATH, &hKey)==ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD permanentBan = on ? 1 : 0;
|
DWORD permanentBan = on ? 1 : 0;
|
||||||
LONG result = RegSetValueEx(hKey, REGKEY_PERMANENT_BAN, 0, REG_DWORD, (LPBYTE)&permanentBan, 4);
|
LONG result = RegSetValueExW(hKey, REGKEY_PERMANENT_BAN, 0, REG_DWORD, (LPBYTE)&permanentBan, 4);
|
||||||
|
|
||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
nlwarning("pb key not created");
|
nlwarning("pb key not created");
|
||||||
|
@ -59,17 +60,20 @@ static bool getPermanentBanRegistryKey()
|
||||||
return false; // not implemented
|
return false; // not implemented
|
||||||
#else
|
#else
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY_RYZOM_PATH, 0, KEY_READ, &hKey)==ERROR_SUCCESS)
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, REGKEY_RYZOM_PATH, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD permanentBan;
|
DWORD permanentBan;
|
||||||
DWORD type;
|
DWORD type;
|
||||||
DWORD dataSize = sizeof(DWORD);
|
DWORD dataSize = sizeof(DWORD);
|
||||||
RegQueryValueEx (hKey, REGKEY_PERMANENT_BAN, 0, &type, (LPBYTE)&permanentBan, &dataSize);
|
|
||||||
|
RegQueryValueExW(hKey, REGKEY_PERMANENT_BAN, 0, &type, (LPBYTE)&permanentBan, &dataSize);
|
||||||
|
|
||||||
if (type == REG_DWORD && dataSize == sizeof(DWORD))
|
if (type == REG_DWORD && dataSize == sizeof(DWORD))
|
||||||
{
|
{
|
||||||
return permanentBan != 0;
|
return permanentBan != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
namespace BGDownloader
|
namespace BGDownloader
|
||||||
{
|
{
|
||||||
|
|
||||||
const char *DownloaderMutexName = "RyzomBgDownloader";
|
const wchar_t *DownloaderMutexName = L"RyzomBgDownloader";
|
||||||
|
|
||||||
ucstring getWrittenSize(uint32 nSize)
|
ucstring getWrittenSize(uint32 nSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,7 +133,7 @@ const uint RYZOM_PID_SHM_ID = 0x6b833f31;
|
||||||
|
|
||||||
// name of the background downloader system-wide mutex
|
// name of the background downloader system-wide mutex
|
||||||
|
|
||||||
extern const char *DownloaderMutexName;
|
extern const wchar_t *DownloaderMutexName;
|
||||||
|
|
||||||
|
|
||||||
// get patch written size in megabytes
|
// get patch written size in megabytes
|
||||||
|
|
|
@ -21,45 +21,47 @@
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
static const wchar_t *AppRegEntry = L"Software\\Nevrax\\RyzomInstall";
|
||||||
const char *CLoginRegistry::AppRegEntry = "Software\\Nevrax\\RyzomInstall";
|
static const wchar_t *LoginStepKeyHandle = L"LoginStep";
|
||||||
static const char *LoginStepKeyHandle = "LoginStep";
|
static const wchar_t *InstallIdKeyHandle = L"InstallId";
|
||||||
static const char *InstallIdKeyHandle = "InstallId";
|
|
||||||
|
|
||||||
//===========================================================================================
|
//===========================================================================================
|
||||||
std::string CLoginRegistry::getProductInstallId()
|
std::string CLoginRegistry::getProductInstallId()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// read value
|
// read value
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, AppRegEntry, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, AppRegEntry, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
const uint keyMaxLength = 1024;
|
const uint keyMaxLength = 1024;
|
||||||
DWORD dwType = 0L;
|
DWORD dwType = 0L;
|
||||||
DWORD dwSize = keyMaxLength;
|
DWORD dwSize = keyMaxLength;
|
||||||
char buffer[keyMaxLength];
|
wchar_t buffer[keyMaxLength];
|
||||||
if(RegQueryValueEx(hKey, InstallIdKeyHandle, NULL, &dwType, (unsigned char *) buffer, &dwSize) == ERROR_SUCCESS && dwType == REG_SZ)
|
if (RegQueryValueExW(hKey, InstallIdKeyHandle, NULL, &dwType, (BYTE *) buffer, &dwSize) == ERROR_SUCCESS && dwType == REG_SZ)
|
||||||
{
|
{
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
return buffer;
|
return wideToUtf8(buffer);
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD dwDisp;
|
DWORD dwDisp;
|
||||||
|
|
||||||
// do not exist, create a new key
|
// do not exist, create a new key
|
||||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, AppRegEntry, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS)
|
if (RegCreateKeyExW(HKEY_CURRENT_USER, AppRegEntry, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
srand((uint32)nl_time(0));
|
srand((uint32)nl_time(0));
|
||||||
uint32 r = rand();
|
uint32 r = rand();
|
||||||
r <<= 16;
|
r <<= 16;
|
||||||
r |= rand();
|
r |= rand();
|
||||||
|
|
||||||
std::string id = NLMISC::toString(r);
|
std::string id = NLMISC::toString(r);
|
||||||
if (RegSetValueEx(hKey, InstallIdKeyHandle, 0L, REG_SZ, (const BYTE *) id.c_str(), (DWORD)(id.size())+1) == ERROR_SUCCESS)
|
|
||||||
|
if (RegSetValueExW(hKey, InstallIdKeyHandle, 0L, REG_SZ, (const BYTE *) utf8ToWice(id), (DWORD)(id.size())+1) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,17 +69,18 @@ std::string CLoginRegistry::getProductInstallId()
|
||||||
uint CLoginRegistry::getLoginStep()
|
uint CLoginRegistry::getLoginStep()
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, AppRegEntry, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, AppRegEntry, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD loginStep = 0;
|
DWORD loginStep = 0;
|
||||||
DWORD type;
|
DWORD type;
|
||||||
DWORD dataSize = sizeof(DWORD);
|
DWORD dataSize = sizeof(DWORD);
|
||||||
RegQueryValueEx (hKey, LoginStepKeyHandle, 0, &type, (LPBYTE) &loginStep, &dataSize);
|
RegQueryValueExW(hKey, LoginStepKeyHandle, 0, &type, (LPBYTE) &loginStep, &dataSize);
|
||||||
if (type == REG_DWORD && dataSize == sizeof(DWORD))
|
if (type == REG_DWORD && dataSize == sizeof(DWORD))
|
||||||
{
|
{
|
||||||
return (uint) loginStep;
|
return (uint) loginStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,10 +89,10 @@ void CLoginRegistry::setLoginStep(uint step)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD dwDisp;
|
DWORD dwDisp;
|
||||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, AppRegEntry, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS)
|
if (RegCreateKeyExW(HKEY_CURRENT_USER, AppRegEntry, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD loginStep = step;
|
DWORD loginStep = step;
|
||||||
RegSetValueEx(hKey, LoginStepKeyHandle, 0L, REG_DWORD, (const BYTE *) &loginStep, sizeof(DWORD));
|
RegSetValueExW(hKey, LoginStepKeyHandle, 0L, REG_DWORD, (const BYTE *) &loginStep, sizeof(DWORD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
struct CLoginRegistry
|
struct CLoginRegistry
|
||||||
{
|
{
|
||||||
// key for the login registry infos
|
|
||||||
static const char *AppRegEntry;
|
|
||||||
// Utility function to get a unique install id from the registry
|
// Utility function to get a unique install id from the registry
|
||||||
static std::string getProductInstallId();
|
static std::string getProductInstallId();
|
||||||
// retrieve login step from the registry (0 if no step yet)
|
// retrieve login step from the registry (0 if no step yet)
|
||||||
|
|
Loading…
Reference in a new issue