|
You last visited: Today at 17:17
Advertisement
[?RELEASE?]Source(ugly, untested) of /dice fix
Discussion on [?RELEASE?]Source(ugly, untested) of /dice fix within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.
07/15/2013, 16:19
|
#1
|
elite*gold: 0
Join Date: Jan 2013
Posts: 348
Received Thanks: 353
|
[?RELEASE?]Source(ugly, untested) of /dice fix
Heyho,
ich weiß nicht obs funtzt oder nicht, und ja ich weiß die Source ist hässlich,
ich hatte diese ganzen Threads von wegen Fix für die /dice Funktion gefunden und habe dann einfach mal am Handy eine (wahrscheinlich buggy) Funktion zum Überschreiben geschrieben.
Es geht an sich um die Funktion number_ex...wenn jemand sieht das es nicht funktioniert, würde ich ihn doch liebend gerne beten es zu fixen und hier im Thread zu posten, das wäre sehr nett ^-^
Naja hier habt ihr die Source:
PHP Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <dlfcn.h>
#include <sys/mman.h>
#include <inttypes.h>
#include "ddetour.h"
void __attribute__ ((constructor)) load(void);
int my_number_ex(int arg1, int arg2)
{
char* error=(char)"no error";
long first = (long)arg1;
long second = (long)arg2;
if(first > second)
{
long tmp_second = second;
second = first;
first = tmp_second;
}
if(first == second)
{
error = "Your arguments are equal!";
}
if(first <= 0 || second <= 0)
{
error = "Someone tried to down your server!\nGo thank TheMarv :P";
}
long the_mod = (second + 1)-first;
if(sizeof(error)!=8)
{
printf("%s caused by: %d %d\n", error, first, second)
return 0;
}
return first + thecore_random() % the_mod;
}
void load(void)
{
printf("By TheMarv\n");
number_ex=(int (*)(int, char *argv[]))detour((void*)0x08315F80,(void *)my_numer_ex, DETOUR_LEN_AUTO);
}
ob es funktioniert weiß ich wie gesagt nicht, ich hoffe schon xD
MfG
|
|
|
07/15/2013, 16:28
|
#2
|
elite*gold: 0
Join Date: Dec 2012
Posts: 64
Received Thanks: 17
|
 work 100%
|
|
|
07/15/2013, 16:48
|
#3
|
elite*gold: 0
Join Date: Jan 2013
Posts: 348
Received Thanks: 353
|
Quote:
Originally Posted by .Bloddy
 work 100%
|
are you sure? are you really, really sure?
|
|
|
07/15/2013, 17:04
|
#4
|
elite*gold: 44
Join Date: May 2010
Posts: 2,053
Received Thanks: 1,747
|
Seems legit because you first need to tell the compiler what thecore_random points to (you cannot call functions by name without introducing their addresses).
The function is roughly the same - except that the error handling looks better to me.
The reference to sys_err is missing though.
|
|
|
07/15/2013, 17:10
|
#5
|
elite*gold: 0
Join Date: Jan 2013
Posts: 348
Received Thanks: 353
|
Quote:
Originally Posted by Mashkin
Seems legit because you first need to tell the compiler what thecore_random points to (you cannot call functions by name without introducing their addresses).
The function is roughly the same - except that the error handling looks better to me.
The reference to sys_err is missing though.
|
i knew i forgot something....could you tell me the address of the thecore_random function?
|
|
|
07/15/2013, 17:42
|
#6
|
elite*gold: 0
Join Date: Mar 2013
Posts: 2,449
Received Thanks: 6,446
|
Ein Tpp:
Wenn bei einer if-Abfrage nur eine Zeile folgt, musst du die geschweiften Klammern nicht machen.
Das Gleiche auch bei Schleifen etc.
So zB:
Spart Zeit am Handy
|
|
|
07/15/2013, 17:47
|
#7
|
elite*gold: 606
Join Date: Apr 2008
Posts: 3,180
Received Thanks: 5,376
|
Quote:
Originally Posted by .Remix.
Ein Tpp:
Wenn bei einer if-Abfrage nur eine Zeile folgt, musst du die geschweiften Klammern nicht machen.
Das Gleiche auch bei Schleifen etc.
So zB:
Spart Zeit am Handy 
|
Sollte man aber trozdem machen, da es zur lesbarkeit beiträgt.
|
|
|
07/15/2013, 18:41
|
#8
|
elite*gold: 0
Join Date: Jan 2013
Posts: 348
Received Thanks: 353
|
Quote:
Originally Posted by .Remix.
Ein Tpp:
Wenn bei einer if-Abfrage nur eine Zeile folgt, musst du die geschweiften Klammern nicht machen.
Das Gleiche auch bei Schleifen etc.
So zB:
Spart Zeit am Handy 
|
jo schon, aber ist nicht so meine Art :P
Ab und zu mach ich es, meistens vergesse ich es einfach xD
|
|
|
07/15/2013, 18:47
|
#9
|
elite*gold: 20
Join Date: Jun 2011
Posts: 2,901
Received Thanks: 3,342
|
Wieso zur hölle schaut eig niemand danach, was fürn rückgabewert number_ex eigentlich hat?
Selbst die Lösung von Luca ist falsch, da er auch nicht drauf geachtet hat.
Hier mal meine Variante (kp ob gut, aber immerhin mitm richtigen Rückgabe-Wert)
in den header:
Code:
unsigned int (*number_ex)(int arg1, int arg2) = (unsigned int(*)(int,int))0x08439620;
int (*thecore_random)() = (int(*)())0x08439610;
in die main.cpp
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <stdbool.h>
#include <dlfcn.h>
#include <sys/mman.h>
#include <inttypes.h>
#include "utils/ddetour.h"
#include "gamefunctions.h"
void __attribute__ ((constructor)) my_load(void);
unsigned int fix_number_ex(int a1, int a2)
{
int temp;
if(a1 <0)
{
a1 += -(a1*2);
}
if(a2 <0)
{
a2 += -(a2*2);
}
if(a1 > a2)
{
temp = a1;
a1 = a2;
a2 = temp;
}
temp = (a2 +1 - a1)
if(temp <= 0)
{
temp = 1;
}
return a1 + thecore_random() % temp;
}
void my_load(void)
{
srand(time(0));
number_ex = (unsigned int (*)(int, int))detour((unsigned int*)0x08439620,(unsigned int *)fix_number_ex, DETOUR_LEN_AUTO, 0);
}
|
|
|
07/15/2013, 19:00
|
#10
|
elite*gold: 0
Join Date: Jan 2013
Posts: 348
Received Thanks: 353
|
Quote:
Originally Posted by xCPx
Wieso zur hölle schaut eig niemand danach, was fürn rückgabewert number_ex eigentlich hat?
Selbst die Lösung von Luca ist falsch, da er auch nicht drauf geachtet hat.
Hier mal meine Variante (kp ob gut, aber immerhin mitm richtigen Rückgabe-Wert)
in den header:
Code:
unsigned int (*number_ex)(int arg1, int arg2) = (unsigned int(*)(int,int))0x08439620;
int (*thecore_random)() = (int(*)())0x08439610;
in die main.cpp
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <stdbool.h>
#include <dlfcn.h>
#include <sys/mman.h>
#include <inttypes.h>
#include "utils/ddetour.h"
#include "gamefunctions.h"
void __attribute__ ((constructor)) my_load(void);
unsigned int fix_number_ex(int a1, int a2)
{
int temp;
if(a1 <0)
{
a1 += -(a1*2);
}
if(a2 <0)
{
a2 += -(a2*2);
}
if(a1 > a2)
{
temp = a1;
a1 = a2;
a2 = temp;
}
temp = (a2 +1 - a1)
if(temp <= 0)
{
temp = 1;
}
return a1 + thecore_random() % temp;
}
void my_load(void)
{
srand(time(0));
number_ex = (unsigned int (*)(int, int))detour((unsigned int*)0x08439620,(unsigned int *)fix_number_ex, DETOUR_LEN_AUTO, 0);
}
|
Und was wenn beide Werte gleich sind? :P
|
|
|
07/15/2013, 19:15
|
#11
|
elite*gold: 20
Join Date: Jun 2011
Posts: 2,901
Received Thanks: 3,342
|
Quote:
Originally Posted by TheMarv :<
Und was wenn beide Werte gleich sind? :P
|
Haste die exception doch drin:
temp = (a2 +1 - a1)
Wenn beide gleich sind ergibt das 1
Und sollte doch 0 rauskommen, so ist es danach durch:
if(temp <= 0)
{
temp = 1;
}
Wd 1
also von daher sollte das alles gefixxt sein.
|
|
|
07/15/2013, 19:45
|
#12
|
elite*gold: 0
Join Date: Jan 2013
Posts: 348
Received Thanks: 353
|
Quote:
Originally Posted by xCPx
Haste die exception doch drin:
temp = (a2 +1 - a1)
Wenn beide gleich sind ergibt das 1
Und sollte doch 0 rauskommen, so ist es danach durch:
if(temp <= 0)
{
temp = 1;
}
Wd 1
also von daher sollte das alles gefixxt sein.
|
achso ja, hatte nur drüber geschaut gehabt xD
naja aber was solls, es werden sowieso ein großteil der server nicht einbauen :P
|
|
|
07/15/2013, 20:11
|
#13
|
elite*gold: 0
Join Date: Feb 2008
Posts: 2,754
Received Thanks: 1,748
|
Gut, dass es uns ohne die ddetour.h was nützt.
|
|
|
07/15/2013, 20:14
|
#14
|
elite*gold: 0
Join Date: Jan 2013
Posts: 348
Received Thanks: 353
|
Quote:
Originally Posted by Computerfreek
Gut, dass es uns ohne die ddetour.h was nützt.
|
die gibts beim thread wie man .so extensions macht mit dabei....
|
|
|
07/15/2013, 23:24
|
#15
|
elite*gold: 405
Join Date: Dec 2007
Posts: 6,615
Received Thanks: 6,358
|
Quote:
Originally Posted by Computerfreek
Gut, dass es uns ohne die ddetour.h was nützt.
|
Eine Detour-Funktion zu schreiben ist nicht sonderlich kompliziert..
Pseudocode
Code:
void detour(void* src, void* dest) {
mprotect von src mit size 5
unsigned char array mit größe 5 erstellen
array[0] = E9
array[1] = dest - src - 5
memcpy von array nach src mit der länge 5
}
|
|
|
 |
|
Similar Threads
|
[RELEASE] Dice Game script (event)
08/02/2011 - EO PServer Guides & Releases - 3 Replies
Hi all, this is a simple event i made for you...
you have to add the npc yourself, but however here is the script!
what is this dice game?
Well, it is gambling..... but on EO :)
|
[RELEASE] NAGC BOARD GAME - INFINITE DICE
12/13/2010 - Grand Chase Hacks, Bots, Cheats & Exploits - 94 Replies
Finally right? Took along time to get this working, so here it is,
This hack freezes the value of your dice to 1, if you have more than one die, it will go down to 1, and stay at 1.
How to use:
1: Download BoardFreezer and extract it with winRAR
2: Run GC_Board_Freezer_32bit (The shortcut)
3: There will be an error message, Just press OK
4: Log into your account. Welcome To Grandchase!
|
[Release] [Untested] Awarding Halos
12/06/2009 - CO2 PServer Guides & Releases - 4 Replies
Im not entirely sure this works but its an idea. Someone try this out or tell me whats wrong please.
Chat.cs
if (Cmd == "/awardtopWarrior")
#region Players
try
{
foreach (Game.Character Player in Game.World.H_Chars.Values)
#endregion
...
|
[Release]Ugly Blue Release
08/30/2009 - CO2 PServer Guides & Releases - 8 Replies
This is another of my websites release
Open Index with notepad The Search For 24.91.136.230 And replace it with your IP adress thats the server stats checker to see if your server is online or no,
http://img502.imageshack.us/img502/9318/uglyblue. jpg
Please Do not flame this was just a quick website,
Below
|
All times are GMT +1. The time now is 17:18.
|
|