Skip to content

Commit 70beabe

Browse files
Changes for v1.0.0.2. Allowed use licenses for premium plugins
1 parent 2ea8963 commit 70beabe

File tree

7 files changed

+182
-109
lines changed

7 files changed

+182
-109
lines changed

ConquerHook/CSV3Hook.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ int ClientVersion = 0, EnableHostName = 0, UpdatedIPS = 0;
3939
BYTE patternDynamic = 0x4F;
4040
char HostName[32] = "";
4141
LPCSTR HeaderConfig = "OpenConquerHook";
42-
DWORD_PTR ServerNameMemoryAddress = 0x005726DC;
42+
// Variables of Settings from .ini file
43+
char ServerName[16] = "ConquerOnline";
44+
DWORD ServerNameMemoryAddress = 0x005726DC;
45+
// Patterns for working connection
4346
BYTE pattern_66XX[] = { 0x85, 0xC0, 0x75, 0x2F, 0x8B, 0x4F, 0x14, 0xE8, 0x0D, 0xF1, 0xFF, 0xFF, 0x83, 0x4D, 0xFC, 0xFF, 0x8B, 0x4D, 0xF4 }; // Version = 66XX
4447
BYTE pattern2_66XX[] = { 0x85, 0xC9, 0x74, 0x0C, 0xFF, 0x75, 0x0C, 0x57, 0xE8, 0x53, 0xF2, 0xFF, 0xFF, 0x89, 0x45 }; // Version = 66XX
4548
BYTE pattern_60XX[] = { 0x85, 0xC0, 0x75, 0x00, 0x8B, 0x4F, 0x00, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x83, 0x4D, 0x00, 0x00, 0x8B, 0x00, 0x00 }; // Version = 60XX
@@ -131,17 +134,10 @@ int __stdcall csv3_connect(SOCKET s, sockaddr_in* name, int len)
131134
}
132135

133136
//Servername Changer By DaRkFox
134-
string input = "ConquerOnline";
135-
GetPrivateProfileStringA(HeaderConfig, "SERVERNAME", "ConquerOnline", (LPSTR)input.c_str(), 128, szConfig);
136-
char buffer[128];
137+
char buffer[16];
137138
if (ServerNameMemoryAddress != 0) {
138-
if (ReadProcessMemory(GetCurrentProcess(), (LPCVOID)ServerNameMemoryAddress, &buffer, sizeof(buffer), NULL)) {
139-
//Input Servername
140-
if (!WriteProcessMemory(GetCurrentProcess(), (LPVOID)ServerNameMemoryAddress, input.c_str(), sizeof(buffer), NULL))
141-
{
142-
//MessageBoxA(NULL, "Error cannot WriteProcessMemory!", "Error", MB_OK + MB_ICONERROR);
143-
}
144-
}
139+
//Input Servername
140+
WriteProcessMemory(GetCurrentProcess(), (LPVOID)ServerNameMemoryAddress, ServerName, sizeof(buffer), NULL);
145141
}
146142
//END Servername Changer
147143

@@ -233,27 +229,27 @@ void csv3_init(HMODULE hModule)
233229
GetPrivateProfileStringA(HeaderConfig, "SERVER_VERSION", "0", szVersionValue, 5, szConfig);
234230
ClientVersion = atoi(szVersionValue);
235231

232+
// Get the servername
233+
GetPrivateProfileStringA(HeaderConfig, "SERVERNAME", "ConquerOnline", ServerName, 16, szConfig);
234+
ServerNameMemoryAddress = GetPrivateProfileIntA(HeaderConfig, "SERVERNAME_MEMORYADDRESS", 0, szConfig);
235+
236236
if (ClientVersion >= 5600) {
237237
//
238238
// hook packet processor
239239
//
240240

241241
bool wildcards[] = { 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1 };
242242
PBYTE match = (PBYTE)FindMemoryPattern(pattern_OLD, wildcards, 19);
243-
ServerNameMemoryAddress = 0x0097FAB8;
243+
244244
if (ClientVersion >= 5700) {
245245
match = (PBYTE)FindMemoryPattern(pattern_56XX, wildcards, 19);
246-
ServerNameMemoryAddress = 0;
247246
}
248247
if (ClientVersion >= 6000) {
249248
match = (PBYTE)FindMemoryPattern(pattern_60XX, wildcards, 19);
250-
ServerNameMemoryAddress = 0;
251-
//ServerNameMemoryAddress = 0x00C67FD0;
252249
}
253250
if (ClientVersion >= 6600) {
254251
match = (PBYTE)FindMemoryPattern(pattern_66XX, wildcards, 19);
255-
ServerNameMemoryAddress = 0;
256-
//ServerNameMemoryAddress = 0x00CD7240;
252+
257253
}
258254

259255
if (match == NULL)

ConquerLoader/CLCore/Models/LoaderConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class LoaderConfig
1010
public bool CloseOnFinish { get; set; }
1111
public bool HighResolution { get; set; }
1212
public bool FullScreen { get; set; }
13+
public bool ServernameChange { get; set; }
1314
public string Title { get; set; }
1415
public string LicenseKey { get; set; }
1516

ConquerLoader/CLCore/Models/ServerConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public class ServerConfiguration
1212
public bool EnableHostName { get; set; }
1313
public bool UseDirectX9 { get; set; }
1414
public string Hostname { get; set; }
15+
public string ServerNameMemoryAddress { get; set; }
1516
}
1617
}

ConquerLoader/CLCore/PluginSystem/PluginLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void LoadPluginsFromAPI(LoaderConfig LoaderConfig)
4747
Plugins = new List<IPlugin>();
4848

4949
HttpClient client = new HttpClient();
50-
HttpResponseMessage response = client.GetAsync("http://localhost/api/v1/167635d839c027b0c965cfa0f995dc43$/GetUserModules/" + LoaderConfig.LicenseKey).Result;
50+
HttpResponseMessage response = client.GetAsync("https://conquerloader.com/api/v1/167635d839c027b0c965cfa0f995dc43$/GetUserModules/" + LoaderConfig.LicenseKey).Result;
5151
if (response.IsSuccessStatusCode)
5252
{
5353
string result = response.Content.ReadAsStringAsync().Result;

ConquerLoader/ConquerLoader/Main.cs

Lines changed: 95 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public Main()
2727
this.Theme = MetroFramework.MetroThemeStyle.Light;
2828
}
2929

30-
/*
31-
* TODO LIST
32-
* Change servername on new clients with encrypted Server.dat (Maybe the best option is find the String of first Server in Server.dat (Decrypting it with the tool in the oc forum) in memory and remplace this with the custom string of LoaderConfig.SelectedServer.ServerName
33-
* */
34-
3530
private void Main_Load(object sender, EventArgs e)
3631
{
3732
LoaderConfig = Core.GetLoaderConfig();
@@ -100,64 +95,106 @@ private void SetServerStatus()
10095

10196
private void BtnStart_Click(object sender, EventArgs e)
10297
{
103-
if (LoaderConfig == null) return;
104-
if (cbxServers.SelectedItem == null) return;
105-
SelectedServer = LoaderConfig.Servers.Where(x => x.ServerName == cbxServers.SelectedItem.ToString()).FirstOrDefault();
106-
if (SelectedServer != null)
98+
try
10799
{
108-
// Save Last Selected
100+
if (LoaderConfig == null) return;
101+
if (cbxServers.SelectedItem == null) return;
109102
SelectedServer = LoaderConfig.Servers.Where(x => x.ServerName == cbxServers.SelectedItem.ToString()).FirstOrDefault();
110-
LoaderConfig.DefaultServer = SelectedServer;
111-
Core.SaveLoaderConfig(LoaderConfig);
112-
if (File.Exists(HookINI))
113-
{
114-
File.Delete(HookINI);
115-
}
116-
// Create first the config used by DLL
117-
File.WriteAllText(HookINI, "[OpenConquerHook]"
118-
+ Environment.NewLine + "HOST=" + SelectedServer.LoginHost
119-
+ Environment.NewLine + "GAMEHOST=" + SelectedServer.GameHost
120-
+ Environment.NewLine + "PORT=" + SelectedServer.LoginPort
121-
+ Environment.NewLine + "GAMEPORT=" + SelectedServer.GamePort
122-
+ Environment.NewLine + "SERVERNAME=" + SelectedServer.ServerName
123-
+ Environment.NewLine + "ENABLE_HOSTNAME=" + (SelectedServer.EnableHostName ? "1" : "0")
124-
+ Environment.NewLine + "HOSTNAME=" + SelectedServer.Hostname
125-
+ Environment.NewLine + "SERVER_VERSION=" + SelectedServer.ServerVersion
126-
);
127-
Core.LogWritter.Write("Created the Hook Configuration");
128-
// Modify Setup of client
129-
string SetupIniPath = Path.Combine(Directory.GetCurrentDirectory(), "ini", "GameSetup.ini");
130-
IniManager parser = new IniManager(SetupIniPath, "ScreenMode");
131-
parser.Write("ScreenMode", "FullScrType", LoaderConfig.FullScreen ? "0" : "1");
132-
if (LoaderConfig.HighResolution)
103+
if (SelectedServer != null)
133104
{
134-
parser.Write("ScreenMode", "ScrWidth", "1024");
135-
parser.Write("ScreenMode", "ScrHeight", "768");
136-
/*
137-
* ScreenModeRecord
138-
* 0 = 800x600, windowed
139-
1 = 800x600, full-screen
140-
2 = 1024x768, windowed
141-
3 = 1024x768, full-screen
142-
* */
143-
parser.Write("ScreenMode", "ScreenModeRecord", LoaderConfig.FullScreen ? "3" : "2");
144-
}
145-
else
146-
{
147-
parser.Write("ScreenMode", "ScrWidth", "800");
148-
parser.Write("ScreenMode", "ScrHeight", "600");
149-
/*
150-
* ScreenModeRecord
151-
* 0 = 800x600, windowed
152-
1 = 800x600, full-screen
153-
2 = 1024x768, windowed
154-
3 = 1024x768, full-screen
155-
* */
156-
parser.Write("ScreenMode", "ScreenModeRecord", LoaderConfig.FullScreen ? "1" : "0");
105+
// Save Last Selected
106+
SelectedServer = LoaderConfig.Servers.Where(x => x.ServerName == cbxServers.SelectedItem.ToString()).FirstOrDefault();
107+
LoaderConfig.DefaultServer = SelectedServer;
108+
Core.SaveLoaderConfig(LoaderConfig);
109+
if (File.Exists(HookINI))
110+
{
111+
File.Delete(HookINI);
112+
}
113+
if (LoaderConfig.ServernameChange)
114+
{
115+
if (SelectedServer.ServerNameMemoryAddress != null && SelectedServer.ServerNameMemoryAddress.Length >= 8) // Detect valid memory address
116+
{
117+
// Nothing to do. Using the specified custom memory address
118+
}
119+
else
120+
{
121+
// Set default recommended for each range of versions
122+
if (SelectedServer.ServerVersion < 5600)
123+
{
124+
SelectedServer.ServerNameMemoryAddress = "0x005726DC";
125+
}
126+
if (SelectedServer.ServerVersion >= 5600)
127+
{
128+
SelectedServer.ServerNameMemoryAddress = "0x0097FAB8";
129+
}
130+
if (SelectedServer.ServerVersion >= 5700)
131+
{
132+
SelectedServer.ServerNameMemoryAddress = "0x009BEA00";
133+
}
134+
if (SelectedServer.ServerVersion >= 6000)
135+
{
136+
SelectedServer.ServerNameMemoryAddress = "0x00A56348";
137+
}
138+
if (SelectedServer.ServerVersion >= 6600)
139+
{
140+
SelectedServer.ServerNameMemoryAddress = "0x00CD7240";
141+
}
142+
}
143+
}
144+
else
145+
{
146+
SelectedServer.ServerNameMemoryAddress = "0";
147+
}
148+
// Create first the config used by DLL
149+
File.WriteAllText(HookINI, "[OpenConquerHook]"
150+
+ Environment.NewLine + "HOST=" + SelectedServer.LoginHost
151+
+ Environment.NewLine + "GAMEHOST=" + SelectedServer.GameHost
152+
+ Environment.NewLine + "PORT=" + SelectedServer.LoginPort
153+
+ Environment.NewLine + "GAMEPORT=" + SelectedServer.GamePort
154+
+ Environment.NewLine + "SERVERNAME=" + SelectedServer.ServerName
155+
+ Environment.NewLine + "ENABLE_HOSTNAME=" + (SelectedServer.EnableHostName ? "1" : "0")
156+
+ Environment.NewLine + "HOSTNAME=" + SelectedServer.Hostname
157+
+ Environment.NewLine + "SERVER_VERSION=" + SelectedServer.ServerVersion
158+
+ Environment.NewLine + "SERVERNAME_MEMORYADDRESS=" + SelectedServer.ServerNameMemoryAddress
159+
);
160+
Core.LogWritter.Write("Created the Hook Configuration");
161+
// Modify Setup of client
162+
string SetupIniPath = Path.Combine(Directory.GetCurrentDirectory(), "ini", "GameSetup.ini");
163+
IniManager parser = new IniManager(SetupIniPath, "ScreenMode");
164+
parser.Write("ScreenMode", "FullScrType", LoaderConfig.FullScreen ? "0" : "1");
165+
if (LoaderConfig.HighResolution)
166+
{
167+
parser.Write("ScreenMode", "ScrWidth", "1024");
168+
parser.Write("ScreenMode", "ScrHeight", "768");
169+
/*
170+
* ScreenModeRecord
171+
* 0 = 800x600, windowed
172+
1 = 800x600, full-screen
173+
2 = 1024x768, windowed
174+
3 = 1024x768, full-screen
175+
* */
176+
parser.Write("ScreenMode", "ScreenModeRecord", LoaderConfig.FullScreen ? "3" : "2");
177+
}
178+
else
179+
{
180+
parser.Write("ScreenMode", "ScrWidth", "800");
181+
parser.Write("ScreenMode", "ScrHeight", "600");
182+
/*
183+
* ScreenModeRecord
184+
* 0 = 800x600, windowed
185+
1 = 800x600, full-screen
186+
2 = 1024x768, windowed
187+
3 = 1024x768, full-screen
188+
* */
189+
parser.Write("ScreenMode", "ScreenModeRecord", LoaderConfig.FullScreen ? "1" : "0");
190+
}
191+
worker.RunWorkerAsync();
157192
}
158-
worker.RunWorkerAsync();
193+
} catch(Exception ex)
194+
{
195+
Core.LogWritter.Write("Error found: " + ex);
159196
}
160-
}
197+
}
161198

162199
private void Worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
163200
{

0 commit comments

Comments
 (0)