View previous topic :: View next topic |
Author |
Message |
DEVCORE Cheater Reputation: 0
Joined: 11 Aug 2018 Posts: 28
|
Posted: Tue Sep 18, 2018 11:01 pm Post subject: Simple Problem - Simple Question - C++ |
|
|
I am separating my code instead of writing it all in main. Practicing to use header files to split up everything. Besides the point I have got a problem.
I am trying to define a function called ReadPlayerInformation() - Inside it I am defining ReadProcessMemory(hProcess) - The problem here is that hProcess is in the main.cpp, how can I use the handle hProcess? Because it cannot find the hProcess from the main? Will post my code below so it will be more easier to see.
[ AddressOffsets.cpp ]
Code: | #pragma once
#include <iostream>
#include <Windows.h>
#include "AddressOffsets.h"
void Player_t::ReadPlayerInformation()
{
ReadProcessMemory(hProcess) <<--- Problem here
}
|
[ Main.cpp ]
Code: | #include <iostream>
#include "Windows.h"
#include "ProcessMemory.h"
#include "AddressOffsets.h"
using namespace std;
int main()
{
DWORD ProcessID;
ProcessID = GetProcessID(L"csgo.exe");
uintptr_t ModuleBaseAddress;
ModuleBaseAddress = GetModuleBaseAddress(ProcessID, L"client_panorama.dll");
HANDLE hProcess;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, ProcessID); |
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25252 Location: The netherlands
|
Posted: Tue Sep 18, 2018 11:17 pm Post subject: |
|
|
make it a global or pass it as a parameter to the constructor of Player_t
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
DEVCORE Cheater Reputation: 0
Joined: 11 Aug 2018 Posts: 28
|
Posted: Tue Sep 18, 2018 11:27 pm Post subject: |
|
|
Dark Byte wrote: | make it a global or pass it as a parameter to the constructor of Player_t |
Any example on how to do it? Sorry really new to coding....
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8515 Location: 127.0.0.1
|
Posted: Wed Sep 19, 2018 12:05 pm Post subject: |
|
|
DEVCORE wrote: | Dark Byte wrote: | make it a global or pass it as a parameter to the constructor of Player_t |
Any example on how to do it? Sorry really new to coding.... |
You should really take the time to learn what you are doing then instead of just immediately jumping into trying to write game hacks.
_________________
- Retired. |
|
Back to top |
|
|
DEVCORE Cheater Reputation: 0
Joined: 11 Aug 2018 Posts: 28
|
Posted: Wed Sep 26, 2018 9:55 pm Post subject: |
|
|
Dark Byte wrote: | make it a global or pass it as a parameter to the constructor of Player_t |
UPDATE: Ok with countless learning from tutorials. I kind of understand abit now. Though how can I pass parameter as a constructer?
Because now I have made hProcess member variable in its own class. hProcess is in another class. For example hProcess member variable is in another class called class1.cpp. And class2.cpp which has Player_t class now needs that hProcess member variable inside its method which is the winapi RPM that requires the handle hProcess - By you’re advice how would I pass it to a constructor?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25252 Location: The netherlands
|
Posted: Wed Sep 26, 2018 11:34 pm Post subject: |
|
|
Look into class constructors and create one with a parameter for the handle and in there assign it to it's own variable
then do new Player_t(handle)
you can of coirse also malebit a public and then ObjectOfPlayer_t.itshandle=handle (or if you created it as a pointer then ObjectOfPlayer_t->itshandle=handle)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8515 Location: 127.0.0.1
|
Posted: Fri Sep 28, 2018 1:44 am Post subject: |
|
|
DEVCORE wrote: | Dark Byte wrote: | make it a global or pass it as a parameter to the constructor of Player_t |
UPDATE: Ok with countless learning from tutorials. I kind of understand abit now. Though how can I pass parameter as a constructer?
Because now I have made hProcess member variable in its own class. hProcess is in another class. For example hProcess member variable is in another class called class1.cpp. And class2.cpp which has Player_t class now needs that hProcess member variable inside its method which is the winapi RPM that requires the handle hProcess - By you’re advice how would I pass it to a constructor? |
You are asking pretty basic C++ questions here.. you should really take the time to learn what you are doing with the language first before trying to use it for game hacking. Using classes, function parameters, constructors etc. are all basic level stuff for C++.
_________________
- Retired. |
|
Back to top |
|
|
DEVCORE Cheater Reputation: 0
Joined: 11 Aug 2018 Posts: 28
|
Posted: Tue Oct 02, 2018 12:22 am Post subject: |
|
|
Dark Byte wrote: | Look into class constructors and create one with a parameter for the handle and in there assign it to it's own variable
then do new Player_t(handle)
you can of coirse also malebit a public and then ObjectOfPlayer_t.itshandle=handle (or if you created it as a pointer then ObjectOfPlayer_t->itshandle=handle) |
Does that mean I need to create another new variable member called hProcess for Player_t struct when passing to constructor?
Is this correct? So every time I want to access a member variable from a different class inside current class. I will need to create a new member variable to assign what is passed through?
Code: |
struct Player_t
{
Int hProcess;
Player_t(HANDLE h)
{
hProcess = h;
}
};
|
|
|
Back to top |
|
|
|