|
You last visited: Today at 11:34
Advertisement
using Hybrid's NativeInterop
Discussion on using Hybrid's NativeInterop within the CO2 Private Server forum part of the Conquer Online 2 category.
08/30/2010, 14:57
|
#1
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
using Hybrid's NativeInterop
<EDIT>
To avoid confusion, I'll re-write the original post so that people aren't answering things that have already been figured out.
Problems Solved:
-Sorting out who sent which packets
Problems I'm currently having:
-msvcrt.dll not working for some unknown reason (works fine in my other test source as well as in immune's source. as soon as I add it as a reference I get the could not find entry point error... really annoying.
Questions I currently have:
-Efficient way to split up packets once I reach the game server stage (won't be long if I can just get the stupid pass crypt working... I have everything else already coded on my other source + basic db already created)
-Efficient way to manage packets being sent from server>client. Am I correct in thinking that running a dedicated thread to manage packets needing to be sent would be the best way to go about it? (so have a dictionary or hashtable containing packets needing to be sent and their destination and then the thread will send them when it's next available?)
|
|
|
08/30/2010, 16:23
|
#2
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
How do you pass data to the packethandler?
|
|
|
08/30/2010, 16:33
|
#3
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Not sure I fully understand what you mean. For now what I'm doing is this simple method where it checks connected clients vs the sender of the data and then invokes the .handler using the data received and the client socket. From sources I've used that's the most common way of running a packet handler. From inside mine though I'm splitting off based on auth stage auth stage 1 using auth cryption, 2+ using blowfish (once I get to that stage)
I haven't done anything as far as splitting packets or anything yet as I'm just working on the auth stage (simple stuff.... but for some reason now I'm having a problem using the password decryption from immune's source. It always used to work for me such as with my old custom source I started on but this time it's giving me Unable to find an entry point named 'memcpy' in DLL 'msvcrt.dll'. which is kinda stupid as hell seeing as it works just fine on my other source and in immune's...
<edit>
Minor debugging done. Only causes the exception when msvcrt.dll is added as a reference (it is in the other projects) but it's not even being used... very strange.
|
|
|
08/30/2010, 16:59
|
#4
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Well to solve your problem of which client sent which date, the socket which you received the data on needs to be paired up with a state object, which you have already done which is fine, but when you send your data on to be handled thats where your having your problem...
Just send the state object to the handler aswell along with the data? :
Code:
public static void Handle_Packet(ClientState Owner, Packet Data)
|
|
|
08/30/2010, 17:07
|
#5
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Sorry for the misunderstanding korv. I'm already moving the stuff to packet handler properly.
I edited the post a few times as I was solving things myself. I was mostly looking for ways that were more efficient in the long run as I've not done this stuff before so wanted some advice.
Now my only real problem is
A: getting the stupid password encryption up and running >.< the msvcrt.dll for some reason is REFUSING to work. If I even add the reference it throws the Unable to find an entry point error... driving me crazy cause afaik that's the only public password encryption system released for the new patches X_X
B: splitting packets once I get to game server (iirc they tend to bunch together and need to be split using the TQClient seal... correct? What's a good way to efficiently manage that?)
|
|
|
08/30/2010, 17:21
|
#6
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
If memcpy isnt working then just do Buffer.BlockCopy instead, does the same thing pretty much just managed.
The server is the one that sends big blocks of packets togeather (3k odd bytes normally), so normally you dont need to worry to much, although ive adopted a different method where you receive the header, then receive the number of bytes defined by the packet length (minues the header of course).
|
|
|
08/30/2010, 17:31
|
#7
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Quote:
Originally Posted by Korvacs
If memcpy isnt working then just do Buffer.BlockCopy instead, does the same thing pretty much just managed. 
|
<edit>
Thanks for the help. I'll bash my head against it a bit later. Bit tired atm.
problem here is that I can't use anything from the dll because as soon as I import it or reference it it throws this error.
I need the use of the rand() and srand() functions it provides (unless I can just interchange the rand and randbyte functions from C#)
Appreciate it as always korv.
<edit yet again>
So turns out it has nothing to do with the srand/rand functions (which should have been clear to me as the error was with the memcpy...
So yah. the problem itself lies within the password cryption .dll from his source. I don't actually see where he used memcpy in it but yah, the actual problem only occurs via...
Code:
Pass = Encoding.ASCII.GetString(
(new ConquerPasswordCryptpographer(User).Decrypt(new Encryption.RC5(rc5Key).Decrypt(Password))));
ran the pass cryption dll through red gate and I see plenty of use of srand and rand but not come across where it's using memcpy yet... not read it all though.
|
|
|
08/30/2010, 17:36
|
#8
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Dunno anything about it tbh, i thought it was released in the programming section but couldnt find it when i looked.
|
|
|
08/30/2010, 18:29
|
#9
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
|
unknownone explains the new encryption in the programming section by memory...
Yes, this topic:
|
|
|
08/30/2010, 18:30
|
#10
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Ok wow... so I ripped the password encryption from the dll so that I could hopefully figure out what the hell was going on with this pos.
So now I get a PInvokeStackImbalance.
I'm using
Code:
[DllImport("msvcrt.dll")]
public static extern int srand(int seed);
[DllImport("msvcrt.dll")]
public static extern int rand();
to fill in the rand() and srand() functions his encryption uses.
Soo... changed the import to be using
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
So FINALLY have it half working but the actual decryption doesn't.. outputting jibberish but at least not throwing errors now.
***.. I think this is the longest I've ever spent on encryption :S
Drives me crazy cause the dll DOES work on my other projects :S
<edit>
Wow I'm a moron. I changed some of the srand/rand's in my original setup.. changed those back and now getting the lovely error w/ the dll again... (still using the reflected pass cryption dll so that's not the problem)
|
|
|
08/30/2010, 18:30
|
#11
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by CptSky
unknownone explains the new encryption in the programming section by memory...
Yes, this topic:

|
Yeah thats the one i couldnt find, evenwhen i searched for Password
|
|
|
08/30/2010, 18:34
|
#12
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Thanks Cpt. That's the dll I was already using (hadn't realized Immune didn't make it lol)
<3 for unknown :P
My ***... so much confusion when trying to sort this out.
Ok so basically I've tested all sorts of things and as SOON as it's imported (either as a reference or using importdll) it causes the error.
So yes... only thing that really needs to be solved here is
Unable to find an entry point named 'memcpy' in DLL 'msvcrt.dll'.
It's NOT caused by the password encryption dll as I originally thought, it's any time I attempt using the srand/rand function (which the dll does on its own)
Code:
[DllImport("msvcrt.dll")]
public static extern int srand(int seed);
is what I'm using for importing. I've also tried using it as a reference, nothing works.
If it's referenced or imported it instantly causes the error.
I've also tried some other versions of dllimport with extra statements such as
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
08/30/2010, 20:30
|
#13
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
|
I really don't understand why... The additionnal information are in general not required.
You are sure that you use the right type for each param?
Code:
[DllImport("msvcrt.dll", EntryPoint = "memcpy")]
public static extern void* memcpy(void* dest, void* src, Int32 num);
|
|
|
08/30/2010, 20:43
|
#14
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Ok... lemme just say this.. I'm not using memcpy AT ALL...
Hell, if I remove any reference to it in my project and comment out any code that is using it I removed the pass encryption as well as any reference or code that invokes it from my source and it STILL causes the error. I have to physically move/delete the .dll for it to work.
It makes absolutely NO sense :S
Ok so this is the ONLY section in the entire source that is directly calling the .dll
Code:
msvcrt.msvcrt.srand(Client.PassSeed);
var rc5Key = new byte[0x10];
for (int i = 0; i < 0x10; i++)
rc5Key[i] = (byte)msvcrt.msvcrt.rand();
Pass = Encoding.ASCII.GetString(
(new ConquerPasswordCryptpographer(User).Decrypt(new Encryption.RC5(rc5Key).Decrypt(Password))));
Pass = Pass.Replace("\0", "");
The conquer pass encryption .dll also only uses the rand and srand functions. I tried using the dll import instead of adding it as a reference and reflecting the .dll but run into the same issue.
I do not need to import the dll (that was just another method I tested)... All I need to do is stop this error from popping up.
Note: strangely, I can use the dll just fine for srand/rand if I do it when the server starts. This error only pops up when a client connects/receives a packet. This makes me guess that this is more an issue where hybrid's socket system is causing a conflict with anything else that uses the msvcrt dll.
|
|
|
08/30/2010, 20:56
|
#15
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
|
If you can't call the DLL. Add the functions to your C# code.
Code:
static long holdrand = 1L;
void srand(unsigned int seed)
{
holdrand = (long) seed;
}
int rand()
{
return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
}
|
|
|
 |
|
Similar Threads
|
Hybrid's source +5018
07/03/2010 - CO2 Private Server - 7 Replies
Well I'm upgrading Hybrid's source past 5017, everything seems good to go, but on logging in, I get thus exception.
http://img256.imageshack.us/img256/4273/63984248. jpg
Anyone know whats wrong?
|
Hybrid's source updated to 5252
05/07/2010 - CO2 Private Server - 13 Replies
Hybrid's source updated to 5252 :D! Rarrr TeratoDragon xD
|
[Help]Hybrid's Source
08/09/2009 - CO2 Private Server - 7 Replies
Hey I find this really confusing. I want to try out this source but I don't know where to start. http://www.elitepvpers.com/forum/co2-pserver-discus sions-questions/203219-release-extremely-basic-but -working-bugless-c-source.html
If anyone can help me on this step by step on msn please add me: [email protected]
|
[Help] Connecting to Hybrid's source.
05/01/2009 - CO2 Private Server - 9 Replies
Hey guys, me again.
I downloaded Hybrid's source, set it all up and ran the server.
When I connect it comes up with "Unable to connect to the game server", now this usually happens when I.P's are wrong, i think, but I only found 1 I.P I had to set, and that was in the client's server.dat
I am supposed to be using a 5017 client, right?
Thanks :mofo:
|
!Leaked C0de From Hybrid's Server!
08/01/2008 - Conquer Online 2 - 5 Replies
case "@egypt":
case "@imemo":
case "@suicide":
{
Kernel.KillPlayer(Client, "A non existent being called God");
break;
}
Also
|
All times are GMT +1. The time now is 11:36.
|
|