Post: Small C++ PS3 Library (Source)
06-08-2014, 07:54 PM #1
seb5594
Proud Former Admin
(adsbygoogle = window.adsbygoogle || []).push({}); Hey NGU Members,

Since no one bothered to make a C++ Tool i thought this would help to get started Smile
This will import the PS3TMAPI DLL (Thanks to Enstone for the method) and you can read/write data (like PS3Lib Extensions).
I want also to thank itsLollo, he helped me to solve some probs :p

    
const WCHAR * dllName = L"ps3tmapi.dll";
HINSTANCE hlib = LoadLibrary(dllName);

typedef int(__cdecl *InitTargetCommsFunction)(void);
typedef int(__cdecl *ConnectFunction)(int, LPWSTR);
typedef int(__cdecl *DisconnectFunction)(int);
typedef int(__cdecl *ProcessListFunction)(int, UINT32*, UINT32*);
typedef int(__cdecl *ProcessAttachFunction)(int, UINT32, UINT32);
typedef int(__cdecl *ProcessContinueFunction) (int, UINT32);
typedef int(__cdecl *ProcessSetMemoryFunction)(int, UINT32, UINT32, UINT64, UINT64, int, BYTE*);
typedef int(__cdecl *ProcessGetMemoryFunction)(int, UINT32, UINT32, UINT64, UINT64, int, BYTE*);

InitTargetCommsFunction InitTargetComms = (InitTargetCommsFunction)GetProcAddress(hlib, "SNPS3InitTargetComms");
ConnectFunction ProcConnectTarget = (ConnectFunction)GetProcAddress(hlib, "SNPS3Connect");
DisconnectFunction ProcDisconnectTarget = (DisconnectFunction)GetProcAddress(hlib, "SNPS3Disconnect");
ProcessListFunction ProcProcessList = (ProcessListFunction)GetProcAddress(hlib, "SNPS3ProcessList");
ProcessAttachFunction ProcProcessAttach = (ProcessAttachFunction)GetProcAddress(hlib, "SNPS3ProcessAttach");
ProcessContinueFunction ProcProcessContinue = (ProcessContinueFunction)GetProcAddress(hlib, "SNPS3ProcessContinue");
ProcessGetMemoryFunction ProcGetMemory = (ProcessGetMemoryFunction)GetProcAddress(hlib, "SNPS3ProcessGetMemory");
ProcessSetMemoryFunction ProcSetMemory = (ProcessSetMemoryFunction)GetProcAddress(hlib, "SNPS3ProcessSetMemory");

INT32 Target = 0xFFFFFFFE;
UINT32 puCount[32];
UINT32 ProcessID;

static void ConnectTarget()
{
try
{
InitTargetComms();
ProcConnectTarget(Target, NULL);
MessageBox(0, L"Succesfully conncted to Dev-Kit", L"Success", MB_OK || MB_ICONINFORMATION);
}
catch (...)
{
MessageBox(0, L"Error while connecting to Dev-Kit", L"Error", MB_OK || MB_ICONSTOP);
}
}

static void Attach()
{
try
{
ProcProcessList(Target, puCount, &ProcessID);
ProcProcessAttach(Target, 0, ProcessID);
ProcProcessContinue(Target, ProcessID);
MessageBox(0, L"Succesfully attached your game", L"Success", MB_OK || MB_ICONINFORMATION);
}
catch (...)
{
MessageBox(0, L"Error while attaching your game", L"Error", MB_OK || MB_ICONSTOP);
}
}

static void SetMemory(UINT32 Address, BYTE *bytes, int sizeOfArray)
{
InitTargetComms();
ProcSetMemory(Target, 0, ProcessID, 0, Address, sizeOfArray, bytes);
}

static BYTE* GetMemory(UINT32 Address, INT32 Length)
{
InitTargetComms();
BYTE* ret = new BYTE[Length];
ProcGetMemory(Target, 0, ProcessID, 0, Address, Length, ret);
return ret;
}

static signed char ReadSByte(UINT32 Address)
{
return (signed char)GetMemory(Address, 1)[0];
}
static BYTE ReadByte(UINT32 Address)
{
return (BYTE)GetMemory(Address, 1)[0];
}
static bool ReadBool(UINT32 Address)
{
return GetMemory(Address, 1)[0] != 0;
}
static INT16 ReadInt16(UINT32 Address)
{
BYTE* read = GetMemory(Address, 2);
std::reverse(read, read + 2);
return *(INT16*)read;
}
static INT32 ReadInt32(UINT32 Address)
{
BYTE* read = GetMemory(Address, 4);
std::reverse(read, read + 4);
return *(INT32*)read;
}
static INT64 ReadInt64(UINT64 Address)
{
BYTE* read = GetMemory(Address, Cool Man (aka Tustin);
std::reverse(read, read + Cool Man (aka Tustin);
return *(INT64*)read;
}
static UINT16 ReadUInt16(UINT32 Address)
{
BYTE* read = GetMemory(Address, 2);
std::reverse(read, read + 2);
return *(UINT16*)read;
}
static UINT32 ReadUInt32(UINT32 Address)
{
BYTE* read = GetMemory(Address, 4);
std::reverse(read, read + 4);
return *(UINT32*)read;
}
static UINT64 ReadUInt64(UINT32 Address)
{
BYTE* read = GetMemory(Address, Cool Man (aka Tustin);
std::reverse(read, read + Cool Man (aka Tustin);
return *(UINT64*)read;
}
static FLOAT ReadFloat(UINT32 Address)
{
BYTE* read = GetMemory(Address, 4);
std::reverse(read, read + 4);
return *(FLOAT*)read;
}
static DOUBLE ReadDouble(UINT32 Address)
{
BYTE* read = GetMemory(Address, Cool Man (aka Tustin);
std::reverse(read, read + Cool Man (aka Tustin);
return *(DOUBLE*)read;
}
static void WriteByte(UINT32 Address, BYTE input)
{
BYTE bytes[] = { input };
SetMemory(Address, bytes, 1);
}
static void WriteSByte(UINT32 Address, signed char input)
{
BYTE bytes[] = { input };
SetMemory(Address, bytes, 1);
}
static void WriteBool(UINT32 Address, bool input)
{
BYTE bytes[] = { input };
bytes[0] = input ? (BYTE)1 : (BYTE)0;
SetMemory(Address, bytes, 1);
}
static void WriteInt16(UINT32 Address, INT16 input)
{
BYTE bytes[2];
*(INT16*)bytes = input;
std::reverse(bytes, bytes + 2);
SetMemory(Address, bytes, 2);
}
static void WriteInt32(UINT32 Address, INT32 input)
{
BYTE bytes[4];
*(INT32*)bytes = input;
std::reverse(bytes, bytes + 4);
SetMemory(Address, bytes, 4);
}
static void WriteInt64(UINT32 Address, INT64 input)
{
BYTE bytes[8];
*(INT64*)bytes = input;
std::reverse(bytes, bytes + Cool Man (aka Tustin);
SetMemory(Address, bytes, Cool Man (aka Tustin);
}
static void WriteUInt16(UINT32 Address, UINT16 input)
{
BYTE bytes[2];
*(UINT16*)bytes = input;
std::reverse(bytes, bytes + 2);
SetMemory(Address, bytes, 2);
}
static void WriteUInt32(UINT32 Address, UINT32 input)
{
BYTE bytes[4];
*(UINT32*)bytes = input;
std::reverse(bytes, bytes + 4);
SetMemory(Address, bytes, 4);
}
static void WriteUInt64(UINT32 Address, UINT64 input)
{
BYTE bytes[8];
*(UINT64*)bytes = input;
std::reverse(bytes, bytes + Cool Man (aka Tustin);
SetMemory(Address, bytes, Cool Man (aka Tustin);
}
static void WriteFloat(UINT32 Address, float input)
{
BYTE bytes[4];
*(float*)bytes = input;
std::reverse(bytes, bytes + 4);
SetMemory(Address, bytes, 4);
}
static void WriteDouble(UINT32 Address, DOUBLE input)
{
BYTE bytes[8];
*(DOUBLE*)bytes = input;
std::reverse(bytes, bytes + Cool Man (aka Tustin);
SetMemory(Address, bytes, Cool Man (aka Tustin);
}
static void WriteString(UINT32 Address, std::string text)
{
SetMemory(Address, (BYTE*)text.c_str(), text.length() + 1);
}
static bool CompareByteArray(BYTE* a, BYTE* b, INT32 ArrayLength)
{
INT32 CheckArray = 0;
for (INT32 i = 0; i < ArrayLength; i++)
if (a[i] == b[i])
CheckArray++;
return CheckArray == ArrayLength;
}
static std::string ReadString(UINT32 Address, INT32 Length)
{
return (reinterpret_cast<const char*>(GetMemory(Address, Length)));
}


I really hope some ppl will take the time to learn some C++, enjoy! :yes:
(adsbygoogle = window.adsbygoogle || []).push({});

The following 19 users say thank you to seb5594 for this useful post:

Azus, Bad Luck Brian, BornShooter, Cyb3r, flynhigh09, Im Not Boobdidas, iMoDz-Baptiste, ItsLollo1000, MegaMister, milky4444, Notorious, Padavona, SnaY, Swiss, SyGnUs, Tustin, Hash847, witchery
06-15-2014, 10:03 PM #11
Originally posted by therifboy View Post
Once again, stop judging the ps3 scene just by knowing ngu. 90% of the ps3 developers code either in C or C++. What programming language do you think homebrews are coded with? The reason C# is used a lot on ngu is because it's better for RTM tools and loading plugins into the game process is not as easy as on Xbox.


You seem to seriously have an issue with me, and I really don't see why? The last time you tried calling me out, it was due to your lack of knowledge. Why bother to keep trying? But I meant the PS3 scene on NGU of-cource you derp. Link me to some more PS3 communities if there is any more, I'd love to see others. The reason why I said what I said is because of what I've seen is just C# RPC applications. Also ha, C# is not better for anything. C# as a whole is just alot more user-friendly and has much more class's, and also handle's data differently. So no I wouldn't ever say it's better at all, just easier. And lol? without Dashlaunch there wouldn't be any "plugins" being loading into there specified location in memory at bootup. I have never once bashed anyone in the PS3 scene for using a "RTM" tool, but instead the face that it's compiled in C#. But with game modding issue's, ever since around 2009/2010 every game has included a function loading images into there specified locations in memory, on xbox this is used to import xam.xex & xboxkrnl.exe into the game memory, to use there native functions. Since i've only ever really done things on xbox, this could be solely an xbox feature. But due to Sony's autistic ASM, and just how they handle things in general, it's most likely written completely different & used different methods to support your console. But yeah, this is how we load .dll's into memory.

So please, can you stop trying to call me out? Here's a deal, add me on skype (byjxsqr) if you ever have an issue with something I post on a forum...it's really starting to annoy me now how you continue to try to seem superior over a forum you like to bash alot due to some of the uneducated members of it. stare

Don't bother quoting me back, just really don't ever bother quoting me again...
06-15-2014, 10:20 PM #12
Originally posted by Bitwise View Post
You seem to seriously have an issue with me, and I really don't see why? The last time you tried calling me out, it was due to your lack of knowledge. Why bother to keep trying? But I meant the PS3 scene on NGU of-cource you derp. Link me to some more PS3 communities if there is any more, I'd love to see others. The reason why I said what I said is because of what I've seen is just C# RPC applications. Also ha, C# is not better for anything. C# as a whole is just alot more user-friendly and has much more class's, and also handle's data differently. So no I wouldn't ever say it's better at all, just easier. And lol? without Dashlaunch there wouldn't be any "plugins" being loading into there specified location in memory at bootup. I have never once bashed anyone in the PS3 scene for using a "RTM" tool, but instead the face that it's compiled in C#. But with game modding issue's, ever since around 2009/2010 every game has included a function loading images into there specified locations in memory, on xbox this is used to import xam.xex & xboxkrnl.exe into the game memory, to use there native functions. Since i've only ever really done things on xbox, this could be solely an xbox feature. But due to Sony's autistic ASM, and just how they handle things in general, it's most likely written completely different & used different methods to support your console. But yeah, this is how we load .dll's into memory.

So please, can you stop trying to call me out? Here's a deal, add me on skype (byjxsqr) if you ever have an issue with something I post on a forum...it's really starting to annoy me now how you continue to try to seem superior over a forum you like to bash alot due to some of the uneducated members of it. stare

Don't bother quoting me back, just really don't ever bother quoting me again...


Why would I have an issue with someone i don't know? Stop feeling too important. And don't we all have a lack of knowledge? If you see yourself as someone who doesn't then you probably need to do something about your narcissism.
I won't link you to any other site since it is not allowed. But if you really want to visit any other, google 'ps3 scene'.

C# might not be faster at runtime, but coding a C# is easier since you will not have to debug to find errors.

Aren't you the one who was banned multiple times from 7s for bashing people?
06-15-2014, 10:26 PM #13
Originally posted by therifboy View Post
Why would I have an issue with someone i don't know? Stop feeling too important. And don't we all have a lack knowledge? If you see yourself as someone who doesn't then you probably need to do something about your narcissism.
I won't link you to any other site since it is not allowed. But if you really want to visit any other, google 'ps3 scene'.

C# might not be faster at runtime, but coding a C# is easier since you will not have to debug to find errors.

Aren't you the one who was banned multiple times from 7s for bashing people?


And that is why I don't exactly get why you keep coming off as butthurt with me? And yes, not everyone can know everything...but why try to correct someone on something you have lack of knowledge on about yourself? that's as illogical as it gets. Also, why else do you think I left my skype behind? lol. And wow, you literally just told me what I just said...Kidding me

And you can look at it that way. I try to be constructive, but sometimes It doesn't come off that way. But hey, we all bash people sometimes right? You can't lie to people about something, if you have an issue with something, you have every right to say so. It depends on how you word it. But no I've never been banned for that lol. It was actually due to an account in 2012 being banned, but it's all been resolved now. Got any more conspiracy theories about me?

EDIT: What do you mean by coding a C#? Doesn't really make sense haha
06-16-2014, 03:32 AM #14
Originally posted by Bitwise View Post
I don't know why you casted the returned object as a constant char when you're using std::string, but okay lol. I also don't know why you have everything as a static member...neither do I know why you used typedef to declare you definitions, you could have simple have done something like this;

    
int (*InitTargetCommsFunction)() = (int(__cdecl*)())GetProcAddress(LoadLibary(L"ps3tmapi.dll"), "SNPS3InitTargetComms");


Much easier, more user friendly and also takes less blocks up.

but for your read string, I don't get why you couldn't of just done this?

    
char*readString(int address, int length)
{
return (char*)GetMemory(address, length);
}


I would have understood what you did if you was casting it as std::string, but you're not XD

But over all it is good to see c++ in the ps3 scene :yes:


To be honest, C++ is kind of useless to use for PS3 Real Time Modding, unless it's the language you're most familiar with.
06-16-2014, 06:56 AM #15
Originally posted by BlackPanther View Post
To be honest, C++ is kind of useless to use for PS3 Real Time Modding, unless it's the language you're most familiar with.


Well, then it's not useless then isit? You only find it useless since you don't know it. If more of you guys did research on loading images into PS3 memory, pfft you probably would be up with xbox right about now.

The following user thanked Bitwise for this useful post:

SC58
09-03-2014, 02:06 PM #16
And for CCAPI please ?
09-12-2014, 12:37 AM #17
Confusing
Climbing up the ladder
fml....................

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo