| View previous topic :: View next topic |
| Author |
Message |
gunminiho Expert Cheater
Reputation: 0
Joined: 15 Dec 2008 Posts: 144 Location: peru
|
Posted: Wed Aug 26, 2009 9:33 am Post subject: C++ compiling problem |
|
|
well this is my first try on making something in C++, well i had lots of errors =) but i minimized to 1 wich is this:
| Code: | | LINK : fatal error LNK1561: You must define an Entry Point |
and this is my code:
| Code: | #include <windows.h>
#include <stdlib.h>
#include "hax.h"
//declare pointers/variables here
LPCVOID Addy= (void*)0x00CDAEBA;
/*------------------------------*/
/*Otras Funciones*/
//main function
void WINAPI Hack()
{
while(true){
// HotKey1
if(GetAsyncKeyState(VK_F1)){
//MEMORY BASIC INFORMATION mbi;
LPVOID * tam=0;
SIZE_T* size=0;
//if(VirtualProtect(Addy,4,PAGE_EXECUTE_READWRITE,PAGE_READONLY)){
ReadProcessMemory(GetCurrentProcess(),Addy,tam,4,size);
*(DWORD*)Addy+=800000;
//}
}
}
}
BOOL APIENTRY DllMain(HINSTANCE hDll, DWORD callReason, LPVOID lpReserved)
{
if(callReason == DLL_PROCESS_ATTACH)
{
//edit your message box here (or create more) by changing what is in the quotation marks
MessageBox(0, "My New Hack ", "Injected", MB_ICONEXCLAMATION | MB_OK);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&Main, 0, 0, 0);
}
return true;
} |
=) maybe im missing something?
Last edited by gunminiho on Wed Aug 26, 2009 12:34 pm; edited 1 time in total |
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Wed Aug 26, 2009 10:17 am Post subject: |
|
|
lol are you making a DLL or an .exe..you have Main, and DllMain.
There is a difference. Google.
|
|
| Back to top |
|
 |
gunminiho Expert Cheater
Reputation: 0
Joined: 15 Dec 2008 Posts: 144 Location: peru
|
Posted: Wed Aug 26, 2009 12:28 pm Post subject: |
|
|
nop a DLL, xP! its just that a lil consufed =). i know the differences well teoricly but both of them has a Main function wich is called at starting the program or inject a DLL =).
and about functions notice that im using a void not a int Main(), it that i usualy use that name for the main fuction for my hacks, i think in C++ its wrong =) i think i noticed the problem
i will rename Main() for Hack().
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Aug 26, 2009 2:39 pm Post subject: |
|
|
your source is fine, just specify that its a DLL in the compiler options
_________________
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Aug 26, 2009 2:57 pm Post subject: |
|
|
| Code: | #include <windows.h>
#include <tchar.h>
LPCVOID Addy= (void*)0x00CDAEBA;
void Hack()
{
while( true )
{
if( GetAsyncKeyState( VK_F1 ) )
{
LPVOID * tam=0;
SIZE_T* size=0;
ReadProcessMemory(GetCurrentProcess(),Addy,tam,4,size);
*(DWORD*)Addy+=800000;
}
Sleep(100);
}
}
BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
if( ul_reason_for_call == DLL_PROCESS_ATTACH)
{
MessageBox(0, _T("My New Hack "), _T("Injected"), MB_ICONEXCLAMATION | MB_OK);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&Hack, 0, 0, 0);
}
return true;
} |
changed a few things to probably what you wanted, like createthread param, also added some sleep in your main loop, also indented it nicer
didn't really look at rest of code
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Wed Aug 26, 2009 3:22 pm Post subject: |
|
|
| Why use ReadProcessMemory when you're already in the process's memory space?
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Aug 26, 2009 4:10 pm Post subject: |
|
|
| also if you're going to obtain the pseudo-handle then you might as well only do it once and store the result in a variable
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Aug 26, 2009 5:27 pm Post subject: |
|
|
| Slugsnack wrote: | | also if you're going to obtain the pseudo-handle then you might as well only do it once and store the result in a variable |
yea wont calling GetCurrentProcess 100 times a second make it slower?
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Aug 26, 2009 5:27 pm Post subject: |
|
|
Just specify the /DLL switch in a linker, otherwise depending on the subsystem option, it's going to be expecting either mainCRTStartup or WinMainCRTStartup as the entry.
Also you can just use a pointer to access the memory.
DWORD* dong = (DWORD*)0x00123456;
*dong = 100;
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Wed Aug 26, 2009 5:29 pm Post subject: |
|
|
| Slugsnack wrote: | | also if you're going to obtain the pseudo-handle then you might as well only do it once and store the result in a variable |
Don't forget to close the handle once you're done with it too.
&Also it'll be better if you place variables outside the loop, instead of putting it in the loop.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Aug 26, 2009 5:43 pm Post subject: |
|
|
| void:] wrote: | | &Also it'll be better if you place variables outside the loop, instead of putting it in the loop. |
This probably wont matter, variables on the stack are typically created within the function scope, so no, you are not declaring a billion variables a second like you may imagine.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Aug 26, 2009 5:47 pm Post subject: |
|
|
| void:] wrote: | | Slugsnack wrote: | | also if you're going to obtain the pseudo-handle then you might as well only do it once and store the result in a variable |
Don't forget to close the handle once you're done with it too.
&Also it'll be better if you place variables outside the loop, instead of putting it in the loop. |
uhm if you do
HWND hWin = GetCurrentProcess()
at the top of the function, then you wouldn't need to close it? o.o
_________________
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Wed Aug 26, 2009 6:36 pm Post subject: |
|
|
| blankrider wrote: | | void:] wrote: | | Slugsnack wrote: | | also if you're going to obtain the pseudo-handle then you might as well only do it once and store the result in a variable |
Don't forget to close the handle once you're done with it too.
&Also it'll be better if you place variables outside the loop, instead of putting it in the loop. |
uhm if you do
HWND hWin = GetCurrentProcess()
at the top of the function, then you wouldn't need to close it? o.o |
Yes, proper coders would know that. He's just a bit stupid, quite a few people have recommended staying away from his help.
Anyway,
you could also use -1 for the HANDLE parameter, but you must type-cast it as a HANDLE first to avoid compiler errors.
|
|
| Back to top |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Wed Aug 26, 2009 8:23 pm Post subject: |
|
|
GetCurrentProcess just returns INVALID_HANDLE_VALUE?
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Aug 26, 2009 8:27 pm Post subject: |
|
|
| Quote: | Remarks
A pseudo handle is a special constant, currently (HANDLE)-1, that is interpreted as the current process handle. For compatibility with future operating systems, it is best to call GetCurrentProcess instead of hard-coding this constant value. The calling process can use a pseudo handle to specify its own process whenever a process handle is required. Pseudo handles are not inherited by child processes.
This handle has the PROCESS_ALL_ACCESS access right to the process object. For more information, see Process Security and Access Rights.
Windows Server 2003 and Windows XP/2000: This handle has the maximum access allowed by the security descriptor of the process to the primary token of the process.
A process can create a "real" handle to itself that is valid in the context of other processes, or that can be inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function. A process can also use the OpenProcess function to open a real handle to itself.
The pseudo handle need not be closed when it is no longer needed. Calling the CloseHandle function with a pseudo handle has no effect. If the pseudo handle is duplicated by DuplicateHandle, the duplicate handle must be closed.
|
yes
_________________
|
|
| Back to top |
|
 |
|