mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +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
|
||||
//
|
||||
HANDLE mutex = CreateMutex (NULL, FALSE, BGDownloader::DownloaderMutexName);
|
||||
HANDLE mutex = CreateMutexW (NULL, FALSE, BGDownloader::DownloaderMutexName);
|
||||
if (mutex)
|
||||
{
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
using namespace NLMISC;
|
||||
|
||||
|
||||
#define REGKEY_RYZOM_PATH "Software\\Nevrax\\ryzom"
|
||||
#define REGKEY_PERMANENT_BAN "PB"
|
||||
#define REGKEY_RYZOM_PATH L"Software\\Nevrax\\ryzom"
|
||||
#define REGKEY_PERMANENT_BAN L"PB"
|
||||
|
||||
|
||||
// ************************************************************
|
||||
|
@ -36,10 +36,11 @@ static void setPermanentBanRegistryKey(bool on)
|
|||
nlinfo("Not implemented");
|
||||
#else
|
||||
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;
|
||||
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)
|
||||
{
|
||||
nlwarning("pb key not created");
|
||||
|
@ -59,17 +60,20 @@ static bool getPermanentBanRegistryKey()
|
|||
return false; // not implemented
|
||||
#else
|
||||
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 type;
|
||||
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))
|
||||
{
|
||||
return permanentBan != 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
namespace BGDownloader
|
||||
{
|
||||
|
||||
const char *DownloaderMutexName = "RyzomBgDownloader";
|
||||
const wchar_t *DownloaderMutexName = L"RyzomBgDownloader";
|
||||
|
||||
ucstring getWrittenSize(uint32 nSize)
|
||||
{
|
||||
|
|
|
@ -133,7 +133,7 @@ const uint RYZOM_PID_SHM_ID = 0x6b833f31;
|
|||
|
||||
// name of the background downloader system-wide mutex
|
||||
|
||||
extern const char *DownloaderMutexName;
|
||||
extern const wchar_t *DownloaderMutexName;
|
||||
|
||||
|
||||
// get patch written size in megabytes
|
||||
|
|
|
@ -21,45 +21,47 @@
|
|||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
const char *CLoginRegistry::AppRegEntry = "Software\\Nevrax\\RyzomInstall";
|
||||
static const char *LoginStepKeyHandle = "LoginStep";
|
||||
static const char *InstallIdKeyHandle = "InstallId";
|
||||
static const wchar_t *AppRegEntry = L"Software\\Nevrax\\RyzomInstall";
|
||||
static const wchar_t *LoginStepKeyHandle = L"LoginStep";
|
||||
static const wchar_t *InstallIdKeyHandle = L"InstallId";
|
||||
|
||||
//===========================================================================================
|
||||
std::string CLoginRegistry::getProductInstallId()
|
||||
{
|
||||
|
||||
|
||||
// read value
|
||||
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;
|
||||
DWORD dwType = 0L;
|
||||
DWORD dwSize = keyMaxLength;
|
||||
char buffer[keyMaxLength];
|
||||
if(RegQueryValueEx(hKey, InstallIdKeyHandle, NULL, &dwType, (unsigned char *) buffer, &dwSize) == ERROR_SUCCESS && dwType == REG_SZ)
|
||||
wchar_t buffer[keyMaxLength];
|
||||
if (RegQueryValueExW(hKey, InstallIdKeyHandle, NULL, &dwType, (BYTE *) buffer, &dwSize) == ERROR_SUCCESS && dwType == REG_SZ)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return buffer;
|
||||
return wideToUtf8(buffer);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
DWORD dwDisp;
|
||||
|
||||
// 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));
|
||||
uint32 r = rand();
|
||||
r <<= 16;
|
||||
r |= rand();
|
||||
|
||||
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 "";
|
||||
}
|
||||
|
||||
|
@ -67,17 +69,18 @@ std::string CLoginRegistry::getProductInstallId()
|
|||
uint CLoginRegistry::getLoginStep()
|
||||
{
|
||||
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 type;
|
||||
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))
|
||||
{
|
||||
return (uint) loginStep;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -86,10 +89,10 @@ void CLoginRegistry::setLoginStep(uint step)
|
|||
{
|
||||
HKEY hKey;
|
||||
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;
|
||||
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
|
||||
{
|
||||
// key for the login registry infos
|
||||
static const char *AppRegEntry;
|
||||
// Utility function to get a unique install id from the registry
|
||||
static std::string getProductInstallId();
|
||||
// retrieve login step from the registry (0 if no step yet)
|
||||
|
|
Loading…
Reference in a new issue