To get a better idea of what is going on, try referring to the C# code instead. It's more modern and up to date compared to the C++ stuff I had released a long time ago, not to mention it probably has more comments. For C++ stuff, you want to just look over all my posted articles and code here on epvp. They are pretty outdated now and if I were coding them again today, they'd look a lot different, but that's just what happens as you become more experienced.
C++ just isn't a good language to use to try and convey new ideas or specific implementations to learn from, so that's why it's impossible to follow the code. Even I have trouble following some of my older stuff, but it's more because of how you have to approach programming when using C++ compared to other languages. That's a main reason I moved on from doing a lot of coding in C++ in favor of C#.
Anyways, there's a lot of concepts you have to be aware of to understand SilkroadSecurity. Overtime, as you learn them, you learn better ways to implement the API, which is why I had so many different versions over the years and never really came up with a "final solution".
First, you need to understand the concepts of TCP programming, Specifically, TCP is a stream of data, not a packet protocol like UDP. This means you have to buffer all your input data and then process it as you go along rather than all at once when you receive it. This is a big hurdle for a lot of people and even today commercial games still improperly use TCP.
Second, you need to understand the
DH Key Exchange. This is part of the first steps for the Silkroad security. This is one of the most complex parts of the security, so it might take some time to understand everything going on.
Third, you just have to understand the Silkroad specific algos that are implemented and referenced in the code. There's no short cut in understanding this as you'd really have to reverse engineer them from the clients again to know what they were doing and your implementation in C++ would look just about the same as the code I have. So you can't really understand what's going on other than what you see in the code unless you talked to someone from Joymax that designed the system.
I wrote an article a while ago talking about the security, but it has some bugs and errors (for example, all my 0x7FF should be 0x7FFF). This was the very first version of my SecurityAPI, but I never got around to updating it. It's still mostly useful to get an idea about stuff though. It's attached to this post. A lot has changed since then too; I'd not recommend using WinSock API but rather a network library like boost::asio. It just makes life easier in the long run. It's more stuff to learn and work with, but it's just part of the deal when you use C++.
Once you understand the whole Silkroad Security system, you then have full control over the packet streams and can do whatever you want. If you are not familiar with proxy concepts, you can write a simple proxy to get started that doesn't use the API, but it won't work for the AgentServer connection unless you come up with a method to detour the client and connect to the correct address yourself (what I did for that to get started was simple write to a text file.)
Everything else you pretty much learn and get familiar with the more time you spend with it. For example, a lot of the design of my C# code might not seem apparent until you go through everything and then "discover" why it's setup as it is. It certainly does take time and patience, but if you are committed to learning about this stuff, you'll get it all down in time.