Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] C++ DLL injection for Main Server

Kal Craker
Joined
Apr 29, 2006
Messages
173
Reaction score
6
Re: [Guide] C++ DLL injection for Main Server

i know,installed the full version and it work like a charm ;)
 
Junior Spellweaver
Loyal Member
Joined
Jul 26, 2006
Messages
158
Reaction score
2
Re: [Guide] C++ DLL injection for Main Server

It's not a resource file, and you still cannot use the Express version.

don't talk poop ..

sure it's possible it's linker option /def:file-path..

you can change it in the linker-settings or add it yourself
 
Junior Spellweaver
Joined
Sep 16, 2006
Messages
187
Reaction score
0
Re: [Guide] C++ DLL injection for Main Server

i'm using Express version :p 2008 :] and all works fine ;)
 
Arrogant Wizard
Loyal Member
Joined
Mar 30, 2007
Messages
745
Reaction score
34
Re: [Guide] C++ DLL injection for Main Server

don't talk poop ..

sure it's possible it's linker option /def:file-path..

you can change it in the linker-settings or add it yourself
And you could use MING or GCC for the same code as well *sigh*

Doesn't change that Express do not support Definition files out of the box.
End of story.
 
Junior Spellweaver
Loyal Member
Joined
Jul 26, 2006
Messages
158
Reaction score
2
Re: [Guide] C++ DLL injection for Main Server

PHP:
//ADD DEF-FILE:
#pragma comment(linker, "/DEF:EXPORTS.def")

//CONTINUE CODE
#include "stdafx.h"
#include "KalHook.h"

HMODULE libraryHandle;

/// 
/// Implementation of the WINBASE.H method GetUserNameA().
/// Required for proxying the ADVAPI32.dll library.
/// 
_declspec(dllexport) BOOL WINAPI GetUserNameA(LPSTR input, LPDWORD buffer)
{
	typedef BOOL (WINAPI* CFunction)(LPSTR input,LPDWORD buffer);
	CFunction getUserName = (CFunction)GetProcAddress(libraryHandle, "GetUserNameA");
	return getUserName(input, buffer);
}

/// 
/// Initialize and attach the KalHooks class to the DLL loading
/// allowing us to do inline assembler and memory editing.
/// 
BOOL WINAPI DllMain(HMODULE module,DWORD action,LPVOID reserved)
{
	libraryHandle = LoadLibraryA("ADVAPI32.dll");
	
	Sword::KalHook *hook = new Sword::KalHook();
	switch(action)
	{
		case DLL_PROCESS_ATTACH:
			hook->Attach();
		break;
		case DLL_THREAD_ATTACH:
			hook->Detach();
		break;
	}
	return true;
}

Here you go.. works on EXPRESS so don't tell me doesn't work
 
Arrogant Wizard
Loyal Member
Joined
Mar 30, 2007
Messages
745
Reaction score
34
Re: [Guide] C++ DLL injection for Main Server

No, still no.

We're talking about what the IDE supports. Not what the Visual C++ compiler supports.
What you can do in C++ is rather irrelevant for the discussion.
 
Junior Spellweaver
Joined
Sep 16, 2006
Messages
187
Reaction score
0
Re: [Guide] C++ DLL injection for Main Server

hmm any one have made what? oO? im bored lol idk what i can do maybe some one a idea?
 
Elite Diviner
Loyal Member
Joined
Nov 20, 2006
Messages
462
Reaction score
1
Re: [Guide] C++ DLL injection for Main Server

angry old people fighting over lollipops... "codes"

shouldnt this be in the guide section...

1. oh and DA, did you ever figure out how to close castle wars?

2. When you start your castle wars, it starts without server having to shutdown and reopen right?
 
Arrogant Wizard
Loyal Member
Joined
Mar 30, 2007
Messages
745
Reaction score
34
Re: [Guide] C++ DLL injection for Main Server

1. oh and DA, did you ever figure out how to close castle wars?
No
2. When you start your castle wars, it starts without server having to shutdown and reopen right?
Yes

But alot of the attemps were really buggy, most likely because the code *did* manage to screw up the stack :p
 
Newbie Spellweaver
Joined
Sep 20, 2006
Messages
71
Reaction score
0
Re: [Guide] C++ DLL injection for Main Server

yyhmm.. I releasing it a lil too late, but i dont had internet connection long time. Nvm. Discussion is about C++ DLL Injection for MSvrT, but i want to present a lil implementation, in Delphi Environment. Maybe for someone will be usefull :)

Code:
library MyAdvAPI;

uses
  Windows;

        //Import GetUserNameA from ADVAPI32.DLL...
        function GetUserNameA(input: LPSTR; buffer: LPDWORD): Boolean; external 'advapi32.dll';

        //Lets export "our's GetUserNameA" to be visible for MainSvrT...
        exports
                GetUserNameA;

  //Here's our core :)
  procedure DllEntryPoint(dwReason: DWord);
  begin
        case dwReason of
              DLL_PROCESS_ATTACH:
                                  begin
                                  //OnLibaryLoad;
                                  {Make poop there}
                                  end;

              DLL_PROCESS_DETACH:
                                  begin
                                  //OnLibaryUnload;
                                  {Make poop there}
                                  end;
              end;

  end;

  //Here everything starts :)
  begin
  DllProc:=@DllEntryPoint;
  DllEntryPoint(DLL_PROCESS_ATTACH);
  end.
 
Initiate Mage
Joined
Mar 2, 2008
Messages
3
Reaction score
0
Re: [Guide] C++ DLL injection for Main Server

:s anyone know a good C++ dll. injector please reply back ^_^
 
Initiate Mage
Joined
Mar 2, 2008
Messages
3
Reaction score
0
Re: [Guide] C++ DLL injection for Main Server

better yet a C++ sql injector :s
 
Junior Spellweaver
Joined
Sep 16, 2006
Messages
187
Reaction score
0
Re: [Guide] C++ DLL injection for Main Server

####################C++#########################

bored? yep -.-

here uhii now you can get 2 skill points @lvl up gzzz...


KalHook.SkillPoints(2);

void Hook::SkillPoints(BYTE PTS)
{
BYTE code[] = {0x83 , 0xC1 , PTS};
MemcpyEx(0x004591B1,(DWORD)&code,3);
}

void SkillPoints(BYTE);


you should know how to use this codes if you have read this topic
###################C++######################
Hook for ChatBox to use IngameCommands (client side)
PHP:
DWORD MyChatBack;



void WINAPI MyChatBox(char* rw)
{

		if (rw[0] =='x')
		Command(rw);
		
}

void Naked MyChatHook()
{
	__asm
	{
		add		esp,4
		mov     eax, esp
		push	eax

		call	MyChatBox

		jmp MyChatBack;
	}
}

void ChatPrint(char *rw)
{

	char  string[256]={0};
	sprintf_s(string,"&\0");
	strcat_s(string,rw);
	DWORD adr = (DWORD)&string;
	__asm 
	{
		mov edx,adr
		PUSH EDX
		mov eax,0x00229518
		push eax
		PUSH 11h
		mov eax,0x00229518
		call eax
	
	}
}




void ChatBox() {
	
	int offset;
	offset=SearchPattern("83 C4 04 85 C0 74 02 EB 26 8B 55 F8 52 68 x x x x 6A 11 E8 x x x x",0x00400000,0x00700000);

	if (offset != 0) {
		Intercept(INST_JMP,offset,(DWORD)MyChatHook,9);
		MyChatBack = offset +9;
	}
}

#####################Delphi######################
Here hf with this you can load KSM files ^^ not full working it's only a basic oO
PHP:
procedure TForm1.Button1Click(Sender: TObject);
var
  myRGB: Array [0..3] of Byte;
  X, Y: Integer;
  MemStream: TMemoryStream;
begin
  X := 0;
  Y := 0;
  MemStream := TMemoryStream.Create;
  if OpenDialog1.Execute = True then
  begin
    MemStream.LoadFromFile(OpenDialog1.FileName);
    MemStream.Position := 4;
    Image1.Picture.Bitmap.Width := 256;
    Image1.Picture.Bitmap.Height := 256;
    for Y := 0 to 256 do
    begin
      for X := 0 to 256 do
      begin
        MemStream.Read(myRGB, 4);
        Image1.Canvas.Pixels[X,Y] := RGB(myRGB[0],myRGB[1],myRGB[2]);
      end;
    end;
    MemStream.Free;
  end;
end;
 
Arrogant Wizard
Loyal Member
Joined
Mar 30, 2007
Messages
745
Reaction score
34
Re: [Guide] C++ DLL injection for Main Server

Neat, regarding the KSM -- The KSM don't contain colour information (that belongs to the KCM), are you sure you aren't mixing them up?

This is how I handle KSM. The KSM handles the different zone types, and how mobs/players behave (collison, pvp, etc.)
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace KalMapEditor 
{
    class Map 
    {
        public ushort Collision;
        public byte Zone;
        public enum Types {
            World        = 0x00,
            OneWayPortal = 0x01,
            Town         = 0x02,
            TwoWayPortal = 0x03,
            PKFree       = 0x04,
            Castle       = 0x10
        };                             
        
        public Map(ushort collision,byte zone) 
        {
             this.Collision = collision;
             this.Zone      = zone; 
        }
    }
}

Code:
        /// <summary>
        /// Load the map into a grid
        /// </summary>
        private bool LoadMap() 
        {
            ushort collision;
            ushort zone;
            
            try 
            {
                using(FileStream fs = new FileStream(Path.GetFullPath(Filename),FileMode.Open)) 
                using(BinaryReader br = new BinaryReader(fs)) 
                {
                    for(int y=255;y>=0;y--) 
                    for(int x=0;x<256;x++) 
                    {
                        collision = br.ReadUInt16();
                        zone      = br.ReadUInt16();
                        
                        switch((byte)zone)
                        {
                            case (byte)Map.Types.Town:
                                Grid[x,y] = new Map(collision,(byte)Map.Types.Town);
                            break;
                            case (byte)Map.Types.Castle:
                                Grid[x,y] = new Map(collision,(byte)Map.Types.Castle);
                            break;
                            case (byte)Map.Types.OneWayPortal:
                                Grid[x,y] = new Map(collision,(byte)Map.Types.OneWayPortal);
                            break;
                            case (byte)Map.Types.TwoWayPortal:
                                Grid[x,y] = new Map(collision,(byte)Map.Types.TwoWayPortal);
                            break;
                            case (byte)Map.Types.PKFree:
                                Grid[x,y] = new Map(collision,(byte)Map.Types.PKFree);
                            break;
                            case (byte)Map.Types.World:
                                Grid[x,y] = new Map(collision,(byte)Map.Types.World);
                            break;
                            default:
                                Grid[x,y] = new Map(collision,(byte)Map.Types.World);
                            break;
                        }
                    }
                }
            } catch(EndOfStreamException) {
                MessageBox.Show("Invalid File");
                return false;
            }

            return true;
        }
 

ToF

Master Summoner
Joined
Jun 12, 2007
Messages
513
Reaction score
170
Re: [Guide] C++ DLL injection for Main Server

got problem when im trying to build the .dll file...


look in the .rar file....


EDIT: nvm.. got it working..
 

Attachments

You must be registered for see attachments list
Last edited:
Elite Diviner
Loyal Member
Joined
Nov 20, 2006
Messages
462
Reaction score
1
Re: [Guide] C++ DLL injection for Main Server

didnt aylen already add this start/stop war in his prem?

the premium version maybe... never seen the hook posted anywhere...
 
Back
Top