[WIP] Get SRO Source Code - by re-writing it

02/22/2019 19:54 Klito*#46
Quote:
Originally Posted by florian0 View Post
As @[Only registered and activated users can see links. Click Here To Register...] said, it could be that the Dll is not loaded (pretty obvious if the ImGui Windows arent visible) or if your ginterface.txt is malformed. It may not be obvious from the ginterface.txt-changes file itself, but you need to add the additional lines in the section named "Create". I've seen ppl append the lines at the end of the file, which is not correct.

To make it easier to troubleshoot, I'd like to ask everyone who is experiencing errors or crashes to supply:
1. the error message being thrown
2. the address (and/or the source line) the debugger stopped at
3. if available, a crash dump of the client

"My client is crashing" leaves too many possibilities open.
The dll is loaded and the console is visible, also i can see the ImGui windows in login screen and the character select screen, the crash come when i select the character to enter the game world this is the debugger screenshot display the where the client stopped

[Only registered and activated users can see links. Click Here To Register...]

the client crash dump show nothing, totally nothing!

Code:
Number of Messages: 0
22.02.2019 21:35:21
Just those two lines only, i'm using a clean client i didn't make any edit except your edits, and yeah i added the ginterface.txt in the "Create" section and here is an img to proof it

[Only registered and activated users can see links. Click Here To Register...]

when i remove the additional lines from the file and start the client with the dll it work without problem and i would be able to see the ImGui after selecting the character in the game world
02/22/2019 19:58 b0ykoe#47
Quote:
Originally Posted by Klito* View Post
The dll is loaded and the console is visible, also i can see the ImGui windows in login screen and the character select screen, the crash come when i select the character to enter the game world this is the debugger screenshot display the where the client stopped

[Only registered and activated users can see links. Click Here To Register...]

the client crash dump show nothing, totally nothing!

Code:
Number of Messages: 0
22.02.2019 21:35:21
Just those two lines only, i'm using a clean client i didn't make any edit except your edits, and yeah i added the ginterface.txt in the "Create" section and here is an img to proof it

[Only registered and activated users can see links. Click Here To Register...]

when i remove the additional lines from the file and start the client with the dll it work without problem and i would be able to see the ImGui after selecting the character in the game world
Insert this into ginterface.txt on line 315 right after GDR_SYSTEM:CIFSystemWnd
Code:
	GDR_FLORIAN0GUIDE:CIFflorian0Guide
	{
		ClientRect=RECT,"0,0,0,0"
		Color=COLOR,"255,250,48,127"
		DDJ=STRING,"icon\\etc\\eventguide_1.ddj"
		FontColor=COLOR,"255,239,153,255"
		FontIndex=INTEGER,"0"
		HAlign=INTEGER,"1"
		ID=INTEGER,"1337"
		Rect=RECT,"5000,250,40,40"
		Style=INTEGER,"0"
		SubSection=STRING,""
		Text=STRING,""
		UV_LB=POINT,"0,1"
		UV_LT=POINT,"0,0"
		UV_RB=POINT,"1,1"
		UV_RT=POINT,"1,0"
		VAlign=INTEGER,"1"
	}
	GDR_FLORIAN0:CIFflorian0
	{
		ClientRect=RECT,"0,0,0,0"
		Color=COLOR,"255,8,214,78"
		DDJ=STRING,"interface\\frame\\mframe_wnd_"
		FontColor=COLOR,"255,255,255,255"
		FontIndex=INTEGER,"0"
		HAlign=INTEGER,"0"
		ID=INTEGER,"1338"
		Rect=RECT,"600,200,400,300"
		Style=INTEGER,"64"
		SubSection=STRING,""
		Text=STRING,"UIIT_PAG_FLORIAN0"
		UV_LB=POINT,"0,1"
		UV_LT=POINT,"0,0"
		UV_RB=POINT,"1,1"
		UV_RT=POINT,"1,0"
		VAlign=INTEGER,"0"
	}
02/23/2019 04:16 florian0#48
Thanks for your answer. It clarified a much ... and is really weird ... 00B3E585 is right inside the parser, after looking for the ":"-separator ...
I know the parser has quite a lot of limitations. But that doesn't make any sense.

The parser lands there if it parsed the Section = Name, ... stuff correctly.

And the parser code you are facing issues with looks like this:
Code:
  IF::ReadLine(NumberOfBytesRead, hFile, &ctrl_name);
  if ( v5 )
  {
    do
    {
      if ( ctrl_name )
      {
        if ( !memcmp(&ctrl_name, &c_closingCurlyBrace, 2u) )
          return;
        separator_pos = strchr(&ctrl_name + 1, ':');
        *separator_pos = 0; // <- you crash here
        type_name = separator_pos + 1;
        sub_B3DEA0(a1, v8, &ctrl_name + 1);
        v10 = v9;
        std::string::assign((v9 + 32), type_name, strlen(type_name));
        CIFTControl::ParseBody(v10, NumberOfBytesRead, hFile);
      }
      IF::ReadLine(NumberOfBytesRead, hFile, &ctrl_name);
    }
    while ( v11 );
  }
The only reason it would crash there is if it doesn't find the ':'-separator. But since your ginterface.txt file looks correct ...

At the Stack-View in x64dbg (bottom right) you can still see the "0,0,0,0","0" from the section header (these are discarded) so i'm assuming it crashes at the first pass ... but that might be a false assumption ...
02/24/2019 12:54 ILowe#49
Hello


I tried a lot, but I didn't manage to run Visual studio 2010
Is there an ideal visual studio 2010 link?

visual studio 2010 open
but there is no response when I open .bat files

Can you help with this?
02/24/2019 14:51 florian0#50
Just run the bat file for visual studio 2010 in the explorer (just double click on it). It will create the Visual Studio Project Files. Then you can open the project (SRO_DevKit.sln) in Visual Studio.
02/25/2019 01:18 ILowe#51
Quote:
Originally Posted by florian0 View Post
Just run the bat file for visual studio 2010 in the explorer (just double click on it). It will create the Visual Studio Project Files. Then you can open the project (SRO_DevKit.sln) in Visual Studio.
vs 2010 open, it doesn't do anything when you click .bat :(
please help me, I've been dealing for days :handsdown:
02/25/2019 14:41 florian0#52
Did you install CMake? Open the make_project_vs2010.cmd with the editor of your choice, then put "pause" in a new line at the end. Whats the output?
03/28/2019 11:39 ZeonNETWORK#53
amazing as always @[Only registered and activated users can see links. Click Here To Register...]

i got some notices about florianguide class
1- the GUI id in our case is 30007 it's dynamically created right?
2- some of silkroad's classes in the notification area like CIFOpenMarketAlramGuide is static id and not even defined by any txt or 2dt (yes it use the NIF new shits) but it has static id, i remember it's 198
3- our notification icon now doesn't have a fixed position on the screen so when you change the resolution , the x and y coordinates become meaningless
4- why not using sub_425AE0 instead of sub_634470 and TB_Func_13 to load the icon
5- i noticed a crash while moving the mouse under the imgui window next to the left of zerk button
03/28/2019 12:01 florian0#54
Quote:
Originally Posted by ZeonNETWORK View Post
amazing as always @[Only registered and activated users can see links. Click Here To Register...]

i got some notices about florianguide class
1- the GUI id in our case is 30007 it's dynamically created right?
2- some of silkroad's classes in the notification area like CIFOpenMarketAlramGuide is static id and not even defined by any txt or 2dt (yes it use the NIF new shits) but it has static id, i remember it's 198
3- our notification icon now doesn't have a fixed position on the screen so when you change the resolution , the x and y coordinates become meaningless
4- why not using sub_425AE0 instead of sub_634470 and TB_Func_13 to load the icon
5- i noticed a crash while moving the mouse under the imgui window next to the left of zerk button
All GUI elements listed in ginterface.txt (and the ones included by files used in here) are created dynamically, but the ID seems to be static, at least for txt.
I'm not sure how the notification area is managed internally. I just managed to create a notification icon. It might create notification icons by itself. If you want it to move with the resolution you have to move it by calling MoveGWnd (i think thats the correct name) for now. I haven't found the notification-alignment code, yet.

sub_425AE0 is std::string::assign. Calling it would cause a crash because there is no memory for it. sub_634470 loads the icon. I'm not entirely sure what it does exactly, but it's kinda different to TB_Func_13. Also, the game loads the icon without a virtual call irrc, so I just mimicked that. I guess you can also just call TB_Func_13 with a string.

I'll look into the crash. Maybe I can reproduce it.
03/28/2019 23:04 ZeonNETWORK#55
Quote:
Originally Posted by florian0 View Post
All GUI elements listed in ginterface.txt (and the ones included by files used in here) are created dynamically, but the ID seems to be static, at least for txt.
exactly they are created dynamically but the id is static, so where to determine that ID if i created more GUI elements?
already tried different IDs on the CIFFlorian0Guide in GInterface.txt which off course crashes eventually

Quote:
Originally Posted by florian0 View Post
sub_425AE0 is std::string::assign. Calling it would cause a crash because there is no memory for it. sub_634470 loads the icon. I'm not entirely sure what it does exactly, but it's kinda different to TB_Func_13. Also, the game loads the icon without a virtual call irrc, so I just mimicked that. I guess you can also just call TB_Func_13 with a string.
i got it, and back to the main post you said the current available controls are the button and static
so if i want more controls how can i get the class members at the first place?
are there any ida plugins which manage to do that?
03/29/2019 00:10 florian0#56
Quote:
Originally Posted by ZeonNETWORK View Post
exactly they are created dynamically but the id is static, so where to determine that ID if i created more GUI elements?
already tried different IDs on the CIFFlorian0Guide in GInterface.txt which off course crashes eventually
You choose the IDs by yourself. They can be any number, starting from about 5 (lower numbers are reserved for closebtn, titletext and drag handle). IDs have to be unique inside a window e.g. every ID should only appear once in CIFflorian0.txt, but can still be used in other GUIs. Same applies for ginterface.txt. Every entry needs to have it's own, unique ID.

Duplicate IDs do not ultimately lead to crashing. Mostly only weird behaviour. What leads to crashing is the fact that almost no code in Silkroad checks if GUI-Elements are actually existing. If you change the ID of CIFflorian0Guide and some code still uses that old ID, it might crash. These crashes usually happen because GetResObj will return 0 if the GUI Element/Window could not be found and the game doesn't check for that.

Code:
// This is fine, as long as 32001 is an existing ID, but will lead to an unavoidable crash if not
g_CGInterface->m_IRM.GetResObj(32001, 1)->SetVisibile(true);
Code:
// Failsafe, but also longer
CIFWnd* obj = g_CGInterface->m_IRM.GetResObj(32001, 1);
if (obj)
    obj->SetVisibile(true);
Quote:
Originally Posted by ZeonNETWORK View Post
i got it, and back to the main post you said the current available controls are the button and static
so if i want more controls how can i get the class members at the first place?
are there any ida plugins which manage to do that?
Button and Static are the ones that have their own classes. Other controls work aswell, but have some limitations. Visually, probably all controls can be used. You can place fancy headers, fake scrollbars and such. The problem is the interaction. Some, like the textbox, don't require their own class to be accessed. You can just treat them as CIFWnd and call GetText to get the content.

So in theory, creating classes for all the different UI Elements is not necessary unless you need some special feature.

But If you're still up to create one: In general, a "working" silkroad class consists of four main parts: A constructor, a destructor, a virtual function table and their runtimeclass stuff. Most of the time, just having the virtual function table is enough since you are not going to construct the object.

I've used ClassInformer for IDA and now Ghidra to find the virtual function tables via RTTI in the sro_client.

Start by figuring out if there are any virtual functions aside from the ones in the base class. Since the game is heavily based on virtuals, you may find interesting stuff there. You don't need to reconstruct the functions you have found. Simply adding the declaration is enough to call it.

Then do the runtimeclass stuff. The RuntimeClass of the object is referenced in the very first entry of the virtual function table (GetRuntimeClass). My code has macros for generating these functions.

You can also figure out the size of the object pretty easy. For example if you want to know the size of CIFButton, you just make a string-search for "CIFButton". Once found, check the references to that string.
[Only registered and activated users can see links. Click Here To Register...]
There may be multiple, the one with the PUSH is usually the correct one. If there is more than one, just look at all of them.
If it looks like this, you found the right one. Look slightly above and you see the total size of CIFButton: 0x3D4
[Only registered and activated users can see links. Click Here To Register...]

(Applies to all objects used in the UI)

Everything is kinda cross-referenced at this point. You can see the address of the RuntimeClass of CIFButton in the screenshot aswell (0x00ee9828). So having either the RuntimeClass address or the typename will lead you to the object size and the virtual function table (Through GetRuntimeClass) and the typename. The screenshot also shows the RuntimeClass of the base-class (0x00ee9720 - CIFStatic).

Constructors and destructors are usually not needed and can be very complex to reverse engineer. I can't give any specific hint on that. It's just bare assembly to c++ conversion using your own (or someone elses) brain.

If you need special behaviour, e.g. like I said before, scrolling, you need to figure out how it works by reverse engineering existing (simple) windows that implement scroll.
04/02/2019 13:58 LordCraft#57
Quote:
Originally Posted by b0ykoe View Post
I've started 2 days ago with @[Only registered and activated users can see links. Click Here To Register...] release and honestly this is fairly easy. Even for someone who has never worked with any C language before.

Huge thanks to him and keep going!

Just want to show some of my progress
[Only registered and activated users can see links. Click Here To Register...]
nice job ! may you can share your code and txt for this scroll menu ?
06/22/2019 10:05 concucu#58
@[Only registered and activated users can see links. Click Here To Register...]

florian0, how to read packet or send packet on this project ?

i cant include #include <cstdint>
06/24/2019 15:03 florian0#59
Quote:
Originally Posted by concucu View Post
@[Only registered and activated users can see links. Click Here To Register...]

florian0, how to read packet or send packet on this project ?

i cant include #include <cstdint>
Networking support is not added yet.

Do you have any error message regarding cstdint? I don't have any issues with includes.
06/25/2019 15:17 chipno0p#60
Quote:
Originally Posted by concucu View Post
@[Only registered and activated users can see links. Click Here To Register...]

florian0, how to read packet or send packet on this project ?

i cant include #include <cstdint>
A simple way to solve this is copy the csdint from Vc100 or other to vc80 and reload the project