|
-
Sep 3rd, 2002, 04:52 AM
#1
Thread Starter
Frenzied Member
*** Decorated Name
I am still overloading my poor vb mind with all this c/c++/asm/.net/***... anyway i am taking a break from interfaces because i felt like that was to much to try and handle in my first .net wrapper for old c++ code. So I am working on something less complex like hacking a vedio game heh.
See I have all the code for the old c++ dll but i came across __cdecl so i looked it up and msdn said and i said how did you get from
Code:
int a(char){int i=3;return i;};
and msdn smiled and told me it wasn't going to explain why it was being used in this source i am converting only that it is very rarely needed.
So could someone give me a reason why it is needed. I am trimming this dll down as it is because it doesn't need all dll export info and the like any longer.
Magiaus
If I helped give me some points.
-
Sep 3rd, 2002, 05:12 AM
#2
Thread Starter
Frenzied Member
ok i see now why he is using __cdecl it is so he can also use __fastcall. I feel that i can safely remve __cdecl and __fastcall with no worries. is this true?
Magiaus
If I helped give me some points.
-
Sep 3rd, 2002, 05:31 AM
#3
Thread Starter
Frenzied Member
am i doing this properly..?
original code
Code:
//////////////////////////////////////////////////////////////////////
// D2HackIt.h
// -------------------------------------------------------------------
// Main incude file for D2HackIt.
//
// <[email protected]>
//////////////////////////////////////////////////////////////////////
#pragma once
#include <windows.h>
#include <iostream>
#include <io.h>
#include <stdio.h>
#include <tlhelp32.h>
#include "LinkedList\LinkedList.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
#define EXPORT __declspec( dllexport ) __cdecl
#define PRIVATE __cdecl
//////////////////////////////////////////////////////////////////////
// Version history.
// -------------------------------------------------------------------
// 0.01 2001-09-22 Bare debug-dll
// 0.02 2001-09-24 Added pattern search code
// 0.03 2001-09-25 Added a few exported function
// 0.04 2001-09-25 Started the client/server API
// 0.05 2001-09-25 Ini-file handling
// 0.06 2001-09-26 Pattern now search for patterns, ordinals & offsets
// 0.07 2001-09-26 Changed the way some GamePrint* functions behave
// 0.08 2001-09-30 Added PSAPI support for NT 4.0
// 0.09 2001-10-01 Removed PSAPI code again, it's buggy
// 0.10 2001-10-10 Started adding game-hooks for events.
// 0.11 2001-10-10 Command line interface started
// 0.12 2001-10-10 Added .load/.unload/.list of modules
// 0.13 2001-10-10 Added maphack 4.1 compatibility
// 0.14 2001-10-10 Added binding & dispatching of client event handlers
// 0.15 2001-10-11 Added GameSendPacketToServer
// 0.16 2001-10-11 Rewrote GamePrintText, the old one didn't wrap properly
// 0.17 2001-10-11 Added much better help functions for commands
// 0.18 2001-10-11 Added .send
// 0.19 2001-10-11 Added commandline inteface for modules.
// 0.20 2001-10-11 Killed a few bugs in the commandline code.
// 0.21 2001-10-12 GameSendPacketToServer now works in single as well
// 0.22 2001-10-14 Rewrote the tokenizer to operate on a copy of the data
// 0.23 2001-10-14 Added GameCommandLine to send commands from modules
// 0.24 2001-10-14 Added FormatString for parsing of controlcodes
// 0.25 2001-10-14 Added .say
// 0.26 2001-10-14 Added SetHackProfileString
// 0.27 2001-10-14 Added hook for GamePlayerInfoIntercept
// 0.28 2001-10-14 Added OnGameJoin/OnGameLeave events
// 0.29 2001-10-15 Interim release, some features nerfed/non working
// 0.30 2001-10-18 Added SHOW_REGS() for debugging the server
// 0.31 2001-10-18 Moved GamePacketReceivedIntercept to work with GrabIt
// 0.32 2001-10-18 Removed a bug where game would crash at b.net login
// 0.33 2001-11-10 Fixed a bug where game would crash when speaking :)
// 0.34 2001-11-13 Fixed so you can cancel incoming packets by returning 0
// 0.35 2001-11-13 Minor fixups
// 0.36 2001-11-14 Fixed GameSendPacketToGame (Thanks to TechWarrior)
// 0.37 2001-11-14 Enabled .received to send packets to game
// 0.38 2001-11-14 Fixed .say
// 0.39 2001-11-14 Added .overhead
// 0.40 2001-11-14 Fixed colorcodes to actually work (Try .say $$1YAY!)
// 0.41 2001-11-15 Export GameSendPacketToGame for modules
// 0.42 2001-11-17 Added OnGameTimerTick event for modules
// 0.43 2001-11-20 Added D2Loader support, still a bit buggy
// 0.44 2001-11-21 Rewrote load/unload of clients to be more reliable
// 0.45 2001-11-21 Removed bugs from D2Loader support and OnTimerTick
// 0.46 2001-12-03 Added .dll to possible module extenstions
// 0.47 2001-12-03 Rewrote GamePacketReceived slightly
// 0.48 2001-12-03 Added .repeat
// 0.49 2001-12-03 Fixed cancelling of sent packets
// 0.50 2001-12-08 Streamlined packet cancelling code a little
// 0.51 2001-12-08 Fixed problem with error messages when exiting d2
// 0.52 2001-12-09 Added | for multiple commands per line (ClckWtchr)
// 0.53 2001-12-09 Fixed a memory leak with |
// 0.54 2001-12-12 D2HackIt is now loadable as a plugin to D2Loader
// Thanks to onlyer for sending the modifications needed!
// 0.55 2001-12-17 Fixed a problem with fingerprints & multiclient
// 0.56 2001-12-24 Added some code sent by sonata + a new loader for multiclient
//////////////////////////////////////////////////////////////////////
#define __SERVERVERSION__ MAKELONG(0,57);
// Sane defaults for prompts
#define DEFAULTINFOPROMPT "ÿc3::ÿc0"
#define DEFAULTERRORPROMPT "ÿc1::ÿc0"
#define DEFAULTVERBOSEPROMPT "ÿc2::ÿc0"
#define MAXPROMPTLENGTH 0x20
#include "Structs.h"
#include "CommonStructs.h"
#define LOADERMAGIC 0xD1AB101D
// ServerStartStop.cpp
BOOL PRIVATE ServerStart(HANDLE hModule);
BOOL PRIVATE ServerStop(void);
// MemorySearchFunctions.cpp
BOOL PRIVATE PatternEquals(LPBYTE buf, LPWORD pat, DWORD plen);
LPVOID PRIVATE PatternSearch(LPBYTE buf, DWORD blen, LPWORD pat, DWORD plen);
VOID PRIVATE MakeSearchPattern(LPCSTR pString, LPWORD pat);
DWORD PRIVATE GetMemoryAddressFromPattern(LPSTR szDllName, LPCSTR szSearchPattern, DWORD offset);
DWORD PRIVATE GetBaseAddress(LPSTR szModuleName);
DWORD PRIVATE GetImageSize(LPSTR szModuleName);
void PRIVATE SetMemToolType(void);
// psapi.cpp
DWORD PRIVATE GetBaseAddress_psapi(LPSTR szModuleName);
DWORD PRIVATE GetImageSize_psapi(LPSTR szModuleName);
BOOL PRIVATE FindImage_psapi(LPSTR ModuleName, MODULEINFO* mi);
// toolhelp.cpp
DWORD PRIVATE GetBaseAddress_toolhelp(LPSTR szModuleName);
DWORD PRIVATE GetImageSize_toolhelp(LPSTR szModuleName);
BOOL PRIVATE FindImage_toolhelp(LPSTR ModuleName, MODULEENTRY32* lpme);
// GameSendPacketToServer.cpp
BOOL EXPORT GameSendPacketToServer(LPBYTE buf, DWORD len);
// GameSendPacketToGame.cpp
BOOL EXPORT GameSendPacketToGame(LPBYTE buf, DWORD len);
// IniFileHandlers.cpp
LPSTR EXPORT GetHackProfileString(LPCSTR lpHackName, LPCSTR lpSectionName, LPCSTR lpKeyName);
BOOL EXPORT SetHackProfileString(LPCSTR lpHackName, LPCSTR lpSectionName, LPCSTR lpKeyName, LPCSTR lpValue);
BOOL EXPORT GetFingerprint(LPCSTR szModule, LPCSTR szFingerprintName, FINGERPRINTSTRUCT &fps);
// GamePrintFunctions.cpp
BOOL EXPORT GamePrintInfo(LPCSTR buf);
BOOL EXPORT GamePrintError(LPCSTR buf);
BOOL EXPORT GamePrintVerbose(LPCSTR buf);
BOOL EXPORT GamePrintString(LPCSTR buf);
// GamePacketReceived.cpp
DWORD __fastcall GamePacketReceivedIntercept(BYTE* aPacket, DWORD aLength);
void GamePacketReceivedInterceptSTUB();
// GamePacketSent.cpp
DWORD __fastcall GamePacketSentIntercept(BYTE* aPacket, DWORD aLength);
void GamePacketSentInterceptSTUB();
// GameSendPacketToServer.cpp
BOOL EXPORT GameSendPacketToServer(LPBYTE buf, DWORD len);
// OtherExportedFunctions.cpp
PTHISGAMESTRUCT EXPORT GetThisgameStruct(void);
// HelperFunctions.cpp
#define INST_NOP 0x90
#define INST_CALL 0xe8
#define INST_JMP 0xe9
VOID* PRIVATE d2memcpy(DWORD lpDest, DWORD lpSource, int len);
BOOL EXPORT Intercept(int instruction, DWORD lpSource, DWORD lpDest, int len);
// FormatString.cpp
DWORD PRIVATE FormatString(LPSTR aString);
// GameCommandLine.cpp
typedef struct gamecommandstruct_t
{
char* szName;
BOOL (PRIVATE *pFunc)(char** argv, int argc);
char* szUsage;
} GAMECOMMANDSTRUCT;
extern GAMECOMMANDSTRUCT GameCommands[];
GAMECOMMANDSTRUCT* PRIVATE FindGameCommand(char* name);
BOOL EXPORT GameCommandLine(char* buf);
BOOL PRIVATE GameCommandLineHelp(char** argv, int argc);
BOOL PRIVATE GameCommandLineVersion(char** argv, int argc);
BOOL PRIVATE GameCommandLineCredits(char** argv, int argc);
BOOL PRIVATE GameCommandLineLoad(char** argv, int argc);
BOOL PRIVATE GameCommandLineUnload(char** argv, int argc);
BOOL PRIVATE GameCommandLineList(char** argv, int argc);
BOOL PRIVATE GameCommandLineSet(char** argv, int argc);
BOOL PRIVATE GameCommandLineSend(char** argv, int argc);
BOOL PRIVATE GameCommandLineReceive(char** argv, int argc);
BOOL PRIVATE GameCommandLineSendkey(char** argv, int argc);
BOOL PRIVATE GameCommandLineSay(char** argv, int argc);
BOOL PRIVATE GameCommandLineOverhead(char** argv, int argc);
BOOL PRIVATE GameCommandLineCrash(char** argv, int argc);
BOOL PRIVATE GameCommandLineTest(char** argv, int argc); // Test function
BOOL PRIVATE GameCommandLineRepeat(char** argv, int argc);
BOOL PRIVATE GameCommandLineClick(char** argv, int argc);
// GamePlayerInfoIntercept.cpp
VOID __fastcall GamePlayerInfoIntercept(PLAYERINFOSTRUCT* pis);
VOID GamePlayerInfoInterceptSTUB();
// TickThread.cpp
DWORD WINAPI TickThread(LPVOID lpParameter);
// Debug helpers
typedef struct regs_t
{
DWORD eax;
DWORD ebx;
DWORD ecx;
DWORD edx;
DWORD esp;
DWORD ebp;
DWORD esi;
DWORD edi;
} REGS;
#define SHOW_REGS(x) REGS __regs;\
fep->GamePrintInfo("Debug: ÿc4" x);\
__asm {mov __regs.eax, eax}\
__asm {mov __regs.ebx, ebx}\
__asm {mov __regs.ecx, ecx}\
__asm {mov __regs.edx, edx}\
__asm {mov __regs.esp, esp}\
__asm {mov __regs.ebp, ebp}\
__asm {mov __regs.esi, esi}\
__asm {mov __regs.edi, edi}\
char __regs_text[128];\
sprintf(__regs_text, "eax: ÿc4%.8xÿc0 ebx: ÿc4%.8xÿc0 ecx: ÿc4%.8xÿc0 edx: ÿc4%.8xÿc0", __regs.eax, __regs.ebx, __regs.ecx, __regs.edx);\
fep->GamePrintInfo(__regs_text);\
sprintf(__regs_text, "esp: ÿc4%.8xÿc0 ebp: ÿc4%.8xÿc0 esi: ÿc4%.8xÿc0 edi: ÿc4%.8xÿc0", __regs.esp, __regs.ebp, __regs.edi, __regs.edi);\
fep->GamePrintInfo(__regs_text);\
#ifdef __cplusplus
} /* Assume C declarations for C++ */
#endif /* __cplusplus */
Magiaus
If I helped give me some points.
-
Sep 3rd, 2002, 05:32 AM
#4
Thread Starter
Frenzied Member
my revamp of the above (post size limt)
code after i removed private, export, __cdecl and __fastcall. this should work as normal constructors now..?
Code:
/************************************************************************************
* Axe.h *
* Main include file for Axe class *
* rewrite/revamp of thohell's Hackit.h *
************************************************************************************/
#pragma once
#include <windows.h>
#include <iostream>
#include <io.h>
#include <stdio.h>
#include <tlhelp32.h>
//#include "LinkedList.h"
#ifdef __cplusplus
extern "C"{/*Assume C declorations for C++ */
#endif /* __cplusplus */
//#define PRIVATE __cdecl
// Sane defaults for prompts
#define DEFAULTINFOPROMPT "ÿc3::ÿc0"
#define DEFAULTERRORPROMPT "ÿc1::ÿc0"
#define DEFAULTVERBOSEPROMPT "ÿc2::ÿc0"
#define MAXPROMPTLENGTH 0x20
#include "Structs.h"
#include "CommonStructs.h"
#define LOADERMAGIC 0xD1AB101D
BOOL ServerStart(HANDLE hModule);
BOOL ServerStop(void);
BOOL PatternEquals(LPBYTE buf, LPWORD pat, DWORD plen);
LPVOID PatternSearch(LPBYTE buf, DWORD blen, LPWORD pat, DWORD plen);
VOID MakeSearchPattern(LPCSTR pString, LPWORD pat);
DWORD GetMemoryAddressFromPattern(LPSTR szDllName, LPCSTR szSearchPattern, DWORD offset);
DWORD GetBaseAddress(LPSTR szModuleName);
DWORD GetImageSize(LPSTR szModuleName);
void SetMemToolType(void);
DWORD GetBaseAddress_psapi(LPSTR szModuleName);
DWORD GetImageSize_psapi(LPSTR szModuleName);
BOOL FindImage_psapi(LPSTR ModuleName, MODULEINFO* mi);
DWORD GetBaseAddress_toolhelp(LPSTR szModuleName);
DWORD GetImageSize_toolhelp(LPSTR szModuleName);
BOOL FindImage_toolhelp(LPSTR ModuleName, MODULEENTRY32* lpme);
BOOL GameSendPacketToServer(LPBYTE buf, DWORD len);
BOOL GameSendPacketToGame(LPBYTE buf, DWORD len);
LPSTR GetHackProfileString(LPCSTR lpHackName, LPCSTR lpSectionName, LPCSTR lpKeyName);
BOOL SetHackProfileString(LPCSTR lpHackName, LPCSTR lpSectionName, LPCSTR lpKeyName, LPCSTR lpValue);
BOOL GetFingerprint(LPCSTR szModule, LPCSTR szFingerprintName, FINGERPRINTSTRUCT &fps);
BOOL GamePrintInfo(LPCSTR buf);
BOOL GamePrintError(LPCSTR buf);
BOOL GamePrintVerbose(LPCSTR buf);
BOOL GamePrintString(LPCSTR buf);
DWORD GamePacketReceivedIntercept(BYTE* aPacket, DWORD aLength);
void GamePacketReceivedInterceptSTUB();
DWORD GamePacketSentIntercept(BYTE* aPacket, DWORD aLength);
void GamePacketSentInterceptSTUB();
BOOL GameSendPacketToServer(LPBYTE buf, DWORD len);
PTHISGAMESTRUCT GetThisgameStruct(void);
// HelperFunctions.cpp
#define INST_NOP 0x90
#define INST_CALL 0xe8
#define INST_JMP 0xe9
VOID* d2memcpy(DWORD lpDest, DWORD lpSource, int len);
BOOL Intercept(int instruction, DWORD lpSource, DWORD lpDest, int len);
// FormatString.cpp
DWORD FormatString(LPSTR aString);
// GameCommandLine.cpp
typedef struct gamecommandstruct_t
{
char* szName;
BOOL (PRIVATE *pFunc)(char** argv, int argc);
char* szUsage;
} GAMECOMMANDSTRUCT;
GAMECOMMANDSTRUCT GameCommands[];
GAMECOMMANDSTRUCT* FindGameCommand(char* name);
BOOL GameCommandLine(char* buf);
BOOL GameCommandLineHelp(char** argv, int argc);
BOOL GameCommandLineVersion(char** argv, int argc);
BOOL GameCommandLineCredits(char** argv, int argc);
BOOL GameCommandLineLoad(char** argv, int argc);
BOOL GameCommandLineUnload(char** argv, int argc);
BOOL GameCommandLineList(char** argv, int argc);
BOOL GameCommandLineSet(char** argv, int argc);
BOOL GameCommandLineSend(char** argv, int argc);
BOOL GameCommandLineReceive(char** argv, int argc);
BOOL GameCommandLineSendkey(char** argv, int argc);
BOOL GameCommandLineSay(char** argv, int argc);
BOOL GameCommandLineOverhead(char** argv, int argc);
BOOL GameCommandLineCrash(char** argv, int argc);
BOOL GameCommandLineTest(char** argv, int argc); // Test function
BOOL GameCommandLineRepeat(char** argv, int argc);
BOOL GameCommandLineClick(char** argv, int argc);
// GamePlayerInfoIntercept.cpp
VOID GamePlayerInfoIntercept(PLAYERINFOSTRUCT* pis);
VOID GamePlayerInfoInterceptSTUB();
// TickThread.cpp
DWORD WINAPI TickThread(LPVOID lpParameter);
// Debug helpers
typedef struct regs_t
{
DWORD eax;
DWORD ebx;
DWORD ecx;
DWORD edx;
DWORD esp;
DWORD ebp;
DWORD esi;
DWORD edi;
} REGS;
#define SHOW_REGS(x) REGS __regs;\
fep->GamePrintInfo("Debug: ÿc4" x);\
__asm {mov __regs.eax, eax}\
__asm {mov __regs.ebx, ebx}\
__asm {mov __regs.ecx, ecx}\
__asm {mov __regs.edx, edx}\
__asm {mov __regs.esp, esp}\
__asm {mov __regs.ebp, ebp}\
__asm {mov __regs.esi, esi}\
__asm {mov __regs.edi, edi}\
char __regs_text[128];\
sprintf(__regs_text, "eax: ÿc4%.8xÿc0 ebx: ÿc4%.8xÿc0 ecx: ÿc4%.8xÿc0 edx: ÿc4%.8xÿc0", __regs.eax, __regs.ebx, __regs.ecx, __regs.edx);\
fep->GamePrintInfo(__regs_text);\
sprintf(__regs_text, "esp: ÿc4%.8xÿc0 ebp: ÿc4%.8xÿc0 esi: ÿc4%.8xÿc0 edi: ÿc4%.8xÿc0", __regs.esp, __regs.ebp, __regs.edi, __regs.edi);\
fep->GamePrintInfo(__regs_text);\
#ifdef __cplusplus
} /* Assume C declarations for C++ */
#endif /* __cplusplus */
i am unsure about
Code:
DWORD WINAPI TickThread(LPVOID lpParameter);
i haven't attempted a build yet because i still have other header files to migrate... i am sure i have some error though....
Magiaus
If I helped give me some points.
-
Sep 3rd, 2002, 06:55 AM
#5
This function must stay as it is, it's a Windows callback.
What would this hack do with poor Diablo 2?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 3rd, 2002, 07:03 AM
#6
Thread Starter
Frenzied Member
which function..?
it really doesn't truely hack it not in truest sense it allows you to do thing like automate actions and make bots and the like. if you work hard and play diablo way to much you could use it to hack but it is hard because you have to monitor packets and intercept them and chage them before they are sent out to the server. I really just like it for stuff like making gold jump in my pocket whenever it hits the ground. as far as i know no one has found a way to make a god mode hack yet
i commented out the .h file include i haven't brought into my project yet and it compiled fine.
Magiaus
If I helped give me some points.
-
Sep 3rd, 2002, 11:15 AM
#7
DWORD WINAPI TickThread(LPVOID lpParameter);
This function
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 3rd, 2002, 11:18 AM
#8
Thread Starter
Frenzied Member
thats what i thought
thanks
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|