Need help writing opcodes in C++

C / C++ Discuss, Need help writing opcodes in C++ at Programmers Lounge forum; Code: #include "stdafx.h" #include <iostream> #include "windows.h" #include "detours.h" #pragma comment(lib,"detours.lib") #pragma comment(lib,"kernel32.lib") #ifdef __cplusplus extern "C" { #endif DWORD ...


Go Back   Gamerz Needs - For All Your Gaming Needs! > Technology Zone > Programmers Lounge > C / C++
Forgot Password? | Sign Up!

Notices

Advertisement
   

Reply
 
Bookmark this Thread Tools Display Modes
  #1  
Old 08-14-2008, 09:39 PM
Z3R0's Avatar
Ethical Hacker
 
Last Online: Yesterday 08:30 PM
Join Date: Sep 2006
Location: South NJ
Age: 20
Posts: 445
Donation Level 5 
Blog Entries: 4
Thanks: 57
Thanked 64 Times in 51 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog: world crashing around me...but i don't care
Rep Power: 6
Z3R0 is on a distinguished road
Points: 188,742.75
Bank: 0.05
Total Points: 188,742.79
cheers man thanks for helping - hadouch 
Send a message via MSN to Z3R0
Need help writing opcodes in C++

Code:
#include "stdafx.h"
#include <iostream>
#include "windows.h"
#include "detours.h"
#pragma comment(lib,"detours.lib")
#pragma comment(lib,"kernel32.lib")
#ifdef __cplusplus
extern "C"
{
#endif
DWORD mplprocid;
HANDLE mplhndl;

DETOUR_TRAMPOLINE(
BOOL WINAPI Mine_ReadProcessMemory(
     HANDLE hProcess,
     LPCVOID lpBaseAddress,
     LPVOID lpBuffer,
     SIZE_T nSize,
     SIZE_T *lpNumberOfBytesRead
), ReadProcessMemory);

DETOUR_TRAMPOLINE(
BOOL WINAPI Mine_WriteProcessMemory(
     HANDLE hProcess,
     LPVOID lpBaseAddress,
     LPCVOID lpBuffer,
     SIZE_T nSize,
     SIZE_T *lpNumberOfBytesWritten
), WriteProcessMemory);

DETOUR_TRAMPOLINE(
HWND WINAPI MineFindWindow(      
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName
), FindWindow);

DETOUR_TRAMPOLINE(
DWORD WINAPI GetCerentProsessId(
	void
	), GetCurrentProcessId);

DETOUR_TRAMPOLINE(
HANDLE WINAPI MineOpenProcess(
    DWORD dwDesiredAccess,
    BOOL bInheritHandle,
    DWORD dwProcessId
), OpenProcess);

#ifdef __cplusplus
}
#endif
BOOL __stdcall WINAPI Real_ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead)
{
	return	Mine_ReadProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead);
}

BOOL __stdcall WINAPI Real_WriteProcessMemory(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesWritten)
{
	return	Mine_WriteProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten);
}

HWND WINAPI Real_FindWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName)
{
	return	MineFindWindow(lpClassName, lpWindowName);
		
}

DWORD __stdcall WINAPI RealGetCerentProsessId(void)
{
	return	GetCerentProsessId();
}

HANDLE __stdcall WINAPI Real_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
{
	return	MineOpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
}

void OpenMapleMeM()
{
		mplprocid = RealGetCerentProsessId();
	    mplhndl =	MineOpenProcess(PROCESS_ALL_ACCESS|PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, mplprocid);
}

void killGG()
{
	BYTE time[5] = {0xB8, 0x55, 0x07, 0x00, 0x00}; 
					
	BYTE low[2] = {0x6A, 0x00};
					
	BYTE peace[5] = {0xE9, 0xF9, 0x57, 0x86, 0x00}; 
					

	OpenMapleMeM();
	Mine_WriteProcessMemory(mplhndl,(LPVOID*)(DWORD)0x865DC6, time, sizeof(time), NULL);
	Mine_WriteProcessMemory(mplhndl,(LPVOID*)(DWORD)0x864A91, low, sizeof(low), NULL);
	Mine_WriteProcessMemory(mplhndl,(LPVOID*)(DWORD)0x86363E, peace, sizeof(peace), NULL);




}

BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{


   switch( dwReason )
   {
   case DLL_PROCESS_ATTACH:{

		DisableThreadLibraryCalls( hModule );
		DetourFunctionWithTrampoline((PBYTE)MineOpenProcess,      (PBYTE)Real_OpenProcess);
		DetourFunctionWithTrampoline((PBYTE)GetCerentProsessId(),      (PBYTE)RealGetCerentProsessId());
		DetourFunctionWithTrampoline((PBYTE)MineFindWindow,		(PBYTE)Real_FindWindow);
	    DetourFunctionWithTrampoline((PBYTE)Mine_ReadProcessMemory,		(PBYTE)Real_ReadProcessMemory);
		DetourFunctionWithTrampoline((PBYTE)Mine_WriteProcessMemory,		(PBYTE)Real_WriteProcessMemory);

		OpenMapleMeM();
		killGG();
		   }
	  return TRUE;
    case DLL_PROCESS_DETACH:
	   {
   		DetourRemove((PBYTE)MineOpenProcess,      (PBYTE)Real_OpenProcess);
		DetourRemove((PBYTE)GetCerentProsessId(),      (PBYTE)RealGetCerentProsessId());
		DetourRemove((PBYTE)MineFindWindow,		(PBYTE)Real_FindWindow);
   	    DetourRemove((PBYTE)Mine_ReadProcessMemory,		(PBYTE)Real_ReadProcessMemory);
		DetourRemove((PBYTE)Mine_WriteProcessMemory,		(PBYTE)Real_WriteProcessMemory);
	   }
      return TRUE;
   }
   return FALSE;
}
It just seems to crash MapleStory...I'm using InjecTOR. Its based on this post:

Quote:
Code:
[ENABLE]
00865DC6:
MOV EAX,755

00864A91:
PUSH 0

0086363E:
jmp 008657f9
What I'm trying to do is modify the respective opcodes at the respective addresses.
__________________

Mysterio-Tom Nguyen 1990-2007

Last edited by Z3R0; 08-14-2008 at 10:57 PM..
  #2  
Old 08-19-2008, 08:39 AM
kaswar's Avatar
Registered Users +
 
Last Online: Today 12:03 PM
Join Date: Nov 2006
Location: Location:
Posts: 2,064
Thanks: 230
Thanked 221 Times in 145 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 11
kaswar will become famous soon enough
Points: 1,091.40
Bank: 110,398.61
Total Points: 111,490.01
Here ya go. Don't get drunk! O.O - joriannn Marked as kashin's property. (One of the four Mighty Titans led by sir SpaceCake) - kashin Merry christmas and seriously i couldnt find any other gift - ItsmYarD Merry Christmas N Happy New Years!!! - BiGbAnG to karwas. Bang - stormer320 
gotcha RPKMHFTAGUITALABPC - ROVE ure not drunk enough yet - swordmas754 
Gold - Wizxon Green - swordmas754 Green - swordmas754 
Send a message via MSN to kaswar
meh i don't get this, hopefully someone can help

*bump*

btw whats opcode?
__________________
Ha I'm back whatever
  #3  
Old 08-19-2008, 09:30 AM
Z3R0's Avatar
Ethical Hacker
 
Last Online: Yesterday 08:30 PM
Join Date: Sep 2006
Location: South NJ
Age: 20
Posts: 445
Blog Entries: 4
Thanks: 57
Thanked 64 Times in 51 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog: world crashing around me...but i don't care
Rep Power: 6
Z3R0 is on a distinguished road
Points: 188,742.75
Bank: 0.05
Total Points: 188,742.79
cheers man thanks for helping - hadouch 
Send a message via MSN to Z3R0
Quote:
Originally Posted by kaswar View Post
meh i don't get this, hopefully someone can help

*bump*

btw whats opcode?
an opcode (operation code) is the portion of a machine language instruction that specifies the operation to be performed.

For example '0xE9' is the 'jmp' instruction.
__________________

Mysterio-Tom Nguyen 1990-2007

Last edited by Z3R0; 08-19-2008 at 10:06 AM..
  #4  
Old 08-19-2008, 01:32 PM
wassssup34579's Avatar
Diamond Hole
 
Last Online: Today 05:09 PM
Join Date: Jan 2007
Location: California
Posts: 756
Blog Entries: 1
Thanks: 144
Thanked 110 Times in 60 Posts
Nominated 6 Times in 3 Posts
TOTW/F/M Award(s): 0
Latest Blog: blahh!!!
Rep Power: 6
wassssup34579 will become famous soon enough
Points: 1,607.20
Bank: 95,830.04
Total Points: 97,437.24
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Send a message via AIM to wassssup34579 Send a message via MSN to wassssup34579
well, for the source you posted, there is no point in hooking the API's. and theres no point of using WriteProcessMemory, if your making a dll. id just write to it directly. (i forgot how to do it in C++, but in delphi it's like pbyte($923582)^:=3; )
  #5  
Old 08-19-2008, 01:35 PM
Sean's Avatar
Gunbound UnderGround Level 3
 
Last Online: Today 02:00 AM
Join Date: Aug 2005
Age: 20
Posts: 4,402
Thanks: 2
Thanked 8,568 Times in 794 Posts
Nominated 33 Times in 17 Posts
Nominated TOTW/F/M Award(s): 1
Latest Blog:
Rep Power: 23
Sean has a spectacular aura aboutSean has a spectacular aura aboutSean has a spectacular aura about
Points: 41,597.46
Bank: 259,569.03
Total Points: 301,166.49
meat vomit - Ken I like people that are switched on up there. - Slugsnack I need no cells hack - huseyin No Message - goblin4u No Message - ahmedangel 
after all those bans, you still get POTM - pilotcs I love how you release only 1 new item to a hack, and get 250 more thanks. gay. =) - pilotcs Hmm. Banana. - Goku Thanks for the great MH ^^ - Adamaniac AwsOme HaCkEr - rebelife56 
I wonder if yours is longer. :) - Crumpeteer_ You Are a Cool friend so good luck and dont forget to eat my burger :)) - humam1992 A nice cold one on me! - kronikill421 best haxor - Plazma No Message - Yokerr 
GregP123 Ownz + Sean Ownz - GregP123 Cheers Sean! - chaosnite192 A beer for awesomeness! - Roguez Keep up the great works on the hacks. - Kyle No Message - jordandll 
Green - JMT420 Gold - Andrex2x Burgundy - Adamaniac Black - gogo_salem Black - shaolin786 
Dark Blue - aaronchanhongsen Gold - bmwm4 Green - hyperzuz Black - gogo_salem Gold - Roguez 
Burgundy - Torai Gold - Denipie 
Quote:
Originally Posted by wassssup34579 View Post
well, for the source you posted, there is no point in hooking the API's. and theres no point of using WriteProcessMemory, if your making a dll. id just write to it directly. (i forgot how to do it in C++, but in delphi it's like pbyte($923582)^:=3; )
Well one way of writing directly in c++ is to just inline asm

__asm{

}

p.s. if this "gg remover" is in demand, I could code one that auto updates..
__________________


Hacks of mine that you can get if you buy premium:
  • Gunz Multi Hack (IJJI)
  • Wolfteam Multi Hack (WIS, WLS)
  • Gunbound Multi Hack (GBNA, GIS, GBEU)
  • Rakion Legit Hack (RIS, RLS, RSS)
So support GzN, buy premium, and start hacking today!
  #6  
Old 08-19-2008, 01:48 PM
wassssup34579's Avatar
Diamond Hole
 
Last Online: Today 05:09 PM
Join Date: Jan 2007
Location: California
Posts: 756
Blog Entries: 1
Thanks: 144
Thanked 110 Times in 60 Posts
Nominated 6 Times in 3 Posts
TOTW/F/M Award(s): 0
Latest Blog: blahh!!!
Rep Power: 6
wassssup34579 will become famous soon enough
Points: 1,607.20
Bank: 95,830.04
Total Points: 97,437.24
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 No Message - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 Black - wassssup34579 
Send a message via AIM to wassssup34579 Send a message via MSN to wassssup34579
Code:
__asm{
  push eax

  mov eax, 00865DC6h
  mov [eax], 0B8h
  mov [eax+1], 55h
  mov [eax+2], 07h
  mov [eax+3], 00h
  mov [eax+4], 00h

  mov eax, 00864A91h
  mov [eax], 6Ah
  mov [eax+1], 00h

  mov eax, 0086363Eh
  mov [eax], 0E9h
  mov [eax], 0F9h
  mov [eax], 57h
  mov [eax], 86h
  mov [eax], 00h

  pop eax
}
it might need to be tweaked a little...
  #7  
Old 08-19-2008, 02:07 PM
kaswar's Avatar
Registered Users +
 
Last Online: Today 12:03 PM
Join Date: Nov 2006
Location: Location:
Posts: 2,064
Thanks: 230
Thanked 221 Times in 145 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 11
kaswar will become famous soon enough
Points: 1,091.40
Bank: 110,398.61
Total Points: 111,490.01
Here ya go. Don't get drunk! O.O - joriannn Marked as kashin's property. (One of the four Mighty Titans led by sir SpaceCake) - kashin Merry christmas and seriously i couldnt find any other gift - ItsmYarD Merry Christmas N Happy New Years!!! - BiGbAnG to karwas. Bang - stormer320 
gotcha RPKMHFTAGUITALABPC - ROVE ure not drunk enough yet - swordmas754 
Gold - Wizxon Green - swordmas754 Green - swordmas754 
Send a message via MSN to kaswar
C++ is

Quote:
(*BYTE)*0x0040000 = 0x90
something like that.
__________________
Ha I'm back whatever
  #8  
Old 08-19-2008, 02:15 PM
Sean's Avatar
Gunbound UnderGround Level 3
 
Last Online: Today 02:00 AM
Join Date: Aug 2005
Age: 20
Posts: 4,402
Thanks: 2
Thanked 8,568 Times in 794 Posts
Nominated 33 Times in 17 Posts
Nominated TOTW/F/M Award(s): 1
Latest Blog:
Rep Power: 23
Sean has a spectacular aura aboutSean has a spectacular aura aboutSean has a spectacular aura about
Points: 41,597.46
Bank: 259,569.03
Total Points: 301,166.49
meat vomit - Ken I like people that are switched on up there. - Slugsnack I need no cells hack - huseyin No Message - goblin4u No Message - ahmedangel 
after all those bans, you still get POTM - pilotcs I love how you release only 1 new item to a hack, and get 250 more thanks. gay. =) - pilotcs Hmm. Banana. - Goku Thanks for the great MH ^^ - Adamaniac AwsOme HaCkEr - rebelife56 
I wonder if yours is longer. :) - Crumpeteer_ You Are a Cool friend so good luck and dont forget to eat my burger :)) - humam1992 A nice cold one on me! - kronikill421 best haxor - Plazma No Message - Yokerr 
GregP123 Ownz + Sean Ownz - GregP123 Cheers Sean! - chaosnite192 A beer for awesomeness! - Roguez Keep up the great works on the hacks. - Kyle No Message - jordandll 
Green - JMT420 Gold - Andrex2x Burgundy - Adamaniac Black - gogo_salem Black - shaolin786 
Dark Blue - aaronchanhongsen Gold - bmwm4 Green - hyperzuz Black - gogo_salem Gold - Roguez 
Burgundy - Torai Gold - Denipie 
Quote:
Originally Posted by wassssup34579 View Post
Code:
__asm{
  push eax

  mov eax, 00865DC6h
  mov [eax], 0B8h
  mov [eax+1], 55h
  mov [eax+2], 07h
  mov [eax+3], 00h
  mov [eax+4], 00h

  mov eax, 00864A91h
  mov [eax], 6Ah
  mov [eax+1], 00h

  mov eax, 0086363Eh
  mov [eax], 0E9h
  mov [eax], 0F9h
  mov [eax], 57h
  mov [eax], 86h
  mov [eax], 00h

  pop eax
}
it might need to be tweaked a little...
definitely needs to be tweaked..

Code:
__asm{
  pushad

  mov eax, 0x00865DC6
  mov dword ptr ds:[eax], 0x000755B8
  mov byte ptr ds:[eax+4], 0x00

  mov eax, 0x00864A91
  mov word ptr ds:[eax], 0x006A

  mov eax, 0x0086363E
  mov byte ptr ds:[eax], 0xE9
  mov ecx, 0x008657F9
  sub ecx, 0x00863643
  mov dword ptr ds:[eax+1], ecx

  popad
}
k that should be good.
__________________


Hacks of mine that you can get if you buy premium:
  • Gunz Multi Hack (IJJI)
  • Wolfteam Multi Hack (WIS, WLS)
  • Gunbound Multi Hack (GBNA, GIS, GBEU)
  • Rakion Legit Hack (RIS, RLS, RSS)
So support GzN, buy premium, and start hacking today!

Last edited by Sean; 08-19-2008 at 02:22 PM..
The Following User Says Thank You to Sean For This Useful Post:
Z3R0 (08-26-2008)
  #9  
Old 08-26-2008, 06:20 AM
run4jit's Avatar
Metal Axe
 
Last Online: Today 07:21 AM
Join Date: May 2008
Posts: 60
Thanks: 4
Thanked 3 Times in 3 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: