Ich verstehe teilweise nur Bahnhof :O
-> Back to topic :
--> Ich verwende jetzt erstmal die Konsole, die sich mit der DLL dann öffnet, darüber ist es ersteinmal
einfacher für mich und ausreichend für meine Anwendungen. Allerdings hätte ich hier mal eine Frage :
Zum Einstieg habe ich mir die Source von xWaffeleisen geholt hier :
Code:
// Coded by xWaffeleisen
// Credits: Eiscremekugel(IlluSsioN) & Disconnect
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <io.h> /* _open_osfhandle */
#include <fcntl.h> /* for _O_TEXT and _O_BINARY */
using namespace std;
DWORD dwKey = 0x0;
DWORD dwDropDelay = 1000;
bool bAutoDrop = false;
DWORD dwDropYangFunc = 0x0;
int iVersion = 0;
void DropYang(int iYang)
{
if (iVersion < 3)
{
__asm
{
MOV ECX,DWORD PTR DS:[0x5F4FC8]
PUSH iYang
PUSH 0
CALL dwDropYangFunc
}
}
else
{
__asm
{
MOV ECX,DWORD PTR DS:[0x5F1CF4]
PUSH iYang
PUSH 0
CALL dwDropYangFunc
}
}
}
/*
MOV ECX,DWORD PTR DS:[5F4FC8]
PUSH EDX
PUSH 0
CALL metin2.0041E020
*/
void Console()
{
int hCrtIn, hCrtOut;
FILE *conIn, *conOut;
AllocConsole();
hCrtIn = _open_osfhandle ((intptr_t) GetStdHandle(STD_INPUT_HANDLE), _O_TEXT);
hCrtOut = _open_osfhandle ((intptr_t) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
conIn = _fdopen( hCrtIn, "r" );
conOut = _fdopen( hCrtOut, "w" );
*stdin = *conIn;
*stdout = *conOut;
}
void CatchKeystrokes(HWND hWnd)
{
bool KeyIsPressed = false;
while (true)
{
while (dwKey != 0x0)
{
if (GetAsyncKeyState(dwKey) < 0)
{
if (!KeyIsPressed)
{
DropYang(1);
}
KeyIsPressed = true;
}
else
{
KeyIsPressed = false;
}
Sleep(5);
}
Sleep(5);
}
}
void AutoDrop()
{
while (true)
{
while (bAutoDrop)
{
DropYang(1);
Sleep(dwDropDelay);
}
Sleep(5);
}
}
void ConsoleThread()
{
char command[255]={0}; // Char zum Einlesen der Eingaben
SetConsoleTitleA("Metin2 YangDropBot by xWaffeleisen"); // Titel ändern
do
{
system("cls");
printf("Please choose your Metin2 Version\n");
printf("1: Metin2 DE\n");
printf("2: Metin2 US\n");
printf("3: Metin35 PServer\n");
printf("\n> ");
scanf_s("%s%*c",&command); // Lesen der Eingabe
if (strcmp ( command , "1" ) == 0)
{
dwDropYangFunc = 0x0041E020;
iVersion = 1;
}
if (strcmp ( command , "2" ) == 0)
{
dwDropYangFunc = 0x0041E0C0;
iVersion = 2;
}
if (strcmp ( command , "3" ) == 0)
{
dwDropYangFunc = 0x0041DEF0;
iVersion = 3;
}
} while (dwDropYangFunc==0x0);
while (1)
{
system("cls");
printf("Commands: start, stop, setdelay, setkey\n\n");
printf("> ");
scanf_s("%s%*c",&command); // Lesen der Eingabe
if (strcmp ( command , "start" ) == 0)
{
bAutoDrop = true;
}
if (strcmp ( command , "stop" ) == 0)
{
bAutoDrop = false;
}
if (strcmp ( command , "setkey" ) == 0)
{
system("cls");
printf("Please insert a Key (F5-F8)\n\n");
printf("> ");
scanf_s("%s%*c",&command); // Lesen der Eingabe
if (strcmp ( command , "F5" ) == 0)
{
dwKey = 0x74;
}
if (strcmp ( command , "F6" ) == 0)
{
dwKey = 0x75;
}
if (strcmp ( command , "F7" ) == 0)
{
dwKey = 0x76;
}
if (strcmp ( command , "F8" ) == 0)
{
dwKey = 0x77;
}
}
if (strcmp ( command , "setdelay" ) == 0)
{
system("cls");
printf("Please insert a Delay (ms)\n\n");
printf("> ");
scanf_s("%s%*c",&command); // Lesen der Eingabe
dwDropDelay = atoi(command);
}
}
}
int __stdcall DllMain(_In_ void * _HDllHandle, _In_ unsigned _Reason, _In_opt_ void * _Reserved)
{
if(DLL_PROCESS_ATTACH == _Reason)
{
Console();
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ConsoleThread, NULL, 0, NULL);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CatchKeystrokes, NULL, 0, NULL);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AutoDrop, NULL, 0, NULL);
}
return 1;
}
Doch bei die Auswahl zwischen 1, 2 und 3 funktioniert iwie nicht richtig. Mir schein das ganze zwar logisch, das Programm gibt auch keine Fehler aus, jedoch klappt dies nicht in der Anwendung.
[Originalthread :
[Only registered and activated users can see links. Click Here To Register...] ]
Mit freundlichen Grüßen,
.Stefan