Hook sdev dlls to ps_game and db_agent files

Nash

Member
Joined
Jan 1, 2024
Messages
9
Greetings community, I'm new around here but not so much in the world of Shaiya private servers.

I've been using @Bowie's wonderful work for a while now but I don't really like using CE to add dll functionality to the server executables. For this reason, I was wondering if there is actually any chance to add the dll's via some procedure.

I have tried to add them through Olly but I find that it is not possible to make the dll's work through the LoadLibraryA instruction, since the dll's do not have an export table.

Any recommendations or advice on how to do this?

Thanks!
 
Sure, there you go

This is my attempt at ps_game.exe:

00553F97 68 E03F5500 PUSH ps_game.00553FE0 ; ASCII "sdev.dll"
00553F9C FF15 C4415500 CALL DWORD PTR DS:[<&KERNEL32.LoadLibrar>; kernel32.LoadLibraryA
00553FA2 68 E93F5500 PUSH ps_game.00553FE9 ; ASCII "EntryPoint"
00553FA7 50 PUSH EAX
00553FA8 FF15 A8415500 CALL DWORD PTR DS:[<&KERNEL32.GetProcAdd>; kernel32.GetProcAddress
00553FAE FFD0 CALL EAX
00553FB0 ^E9 E08FFCFF JMP ps_game.<ModuleEntryPoint>
00553FB5 90 NOP
00553FE0 -73 64 JNB SHORT ps_game.00554046
00553FE2 65:76 2E JBE SHORT ps_game.00554013 ; Superfluous prefix
00553FE5 64:6C INS BYTE PTR ES:[EDI],DX ; I/O command
00553FE7 6C INS BYTE PTR ES:[EDI],DX ; I/O command
00553FE8 00 DB 00
00553FE9 45 INC EBP
00553FEA 6E OUTS DX,BYTE PTR ES:[EDI] ; I/O command
00553FEB -74 72 JE SHORT ps_game.0055405F
00553FED -79 50 JNS SHORT ps_game.0055403F
00553FEF 6F OUTS DX,DWORD PTR ES:[EDI] ; I/O command
00553FF0 696E 74 0000000>IMUL EBP,DWORD PTR DS:[ESI+74],0

I have tried changing the EntryPoint to the new one I have created but what I get in that case is an immediate error when running the executable.
I'm probably doing something wrong, but at this point I'm a bit lost.
I will be very grateful for any help or guidance you can give me

Regards.
 
the LoadLibraryA call looks fine. if you just want to load the library, you don't need the rest of the code. if you tell me which file you're using (or upload the one you edited), i can post an explanation. i started to add a snip, but i think it will make it more confusing. edit: i'm betting `eax` is null when it's called. i need to see the edited file to know for sure.
 
The file I am using is the one you distribute with the dll source, it is the ps_game inside the V2 folder.
By the way, thank you very much for your prompt replies.
 
I think the problem is to change the EntryPoint. For some reason when I move the EOP the executable dies.
If I don't change it, the executable runs, but it doesn't load the dll. It's a bit strange.

As I understand from what you said in the previous message, just hooking the dll should work?
I am a bit confused here, whenever I have done this kind of procedure, I have created a new EOP, in this case it is not required?

The edited file is attached.

Sorry, I should edit my previous message instead add a new one.
 

Attachments

  • ps_game-edited.zip
    716.3 KB · Views: 3
Last edited:
It works like a charm!

I knew I was getting something wrong. I spent all afternoon on this and it only took you a couple of minutes, you're phenomenal :D
I am reviewing the changes to understand what you have done and try now to hook the dll in db_agent.

If I have problems, can I bother you again?

Thank you very much!
 
If I have problems, can I bother you again?

Thank you very much!
sure, i'll try to help if i can. it's no problem. it took me a long time to figure out how to do stuff like this too, so it's not just you. i spent days looking for a simple tutorial. i ended up studying files with these mods to learn.
 
sure, i'll try to help if i can. it's no problem. it took me a long time to figure out how to do stuff like this too, so it's not just you. i spent days looking for a simple tut with no luck. i ended up studying files with these mods to learn. it's hard to find info about this stuff sometimes.
I completely agree, these days it is hard to find information about these procedures and people willing like you, to help when things get complicated.
edit: i realize uploading files like this to my repo would make people's lives easier, but it gives me anxiety to upload modified server binaries. there's already so many things i can screw up in this situation and i'd like to have one less thing to worry about.
I understand what you are saying, the same thing happens to me, I am very conservative in that aspect, but you could for example add the modified executables as optional and that way those who need them will know in advance that the files are not original and that they are modified to work with your dll's. But this is just an idea and I am not trying to tell you what to do with your work, which by the way, is wonderful.

Again I want to thank you for this great help. We are trying to set up a server and things are not going quite right, but this is really an invaluable help for us.
 
But this is just an idea and I am not trying to tell you what to do with your work, which by the way, is wonderful.
a lot of the changes i make are based on feedback. i guess it wouldn't hurt to add some in a separate directory.
 
a lot of the changes i make are based on feedback. i guess it wouldn't hurt to add some in a separate directory. i just updated the Main function in both projects to make it easier to export. i also added a suggestion of how to do it in the wiki.
I'm sure we'll see each other here often. I hope to be useful for this project at some point, although my developer skills are already a bit rusty.
 
@Bowie
I just wanted to let you know that I have added the code block for the exports in the dlls and it works perfectly.
I have managed to add both dlls without problems with CFF explorer.
I would like to leave as a note that the import method must be by ordinal, otherwise it will not work.
 
I just wanted to let you know that I have added the code block for the exports in the dlls and it works perfectly.
that's good to know. whether you realize it or not, you're already useful to the project. i'm about to upload a commit that changes the way the gift enable variable is set, so it's friendly to all means of injection.
 
Back
Top