Post: SPRX C++ help needed
10-05-2014, 08:22 PM #1
optantic
Pokemon Trainer
(adsbygoogle = window.adsbygoogle || []).push({}); I downloaded the sprx Project Source code from BaSs HaXoR , it comes with prx.cpp and Builds fine


#include "stdafx.h"
#include <cellstatus.h>
#include <sys/prx.h>
#include <sys/timer.h>
#include <sys/syscall.h>
#include <sys/ppu_thread.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/memory.h>
#include <typeinfo>

SYS_MODULE_INFO( PS3_PPU_Project1, 0, 1, 1);
SYS_MODULE_START( _PS3_PPU_Project1_prx_entry );

SYS_LIB_DECLARE_WITH_STUB( LIBNAME, SYS_LIB_AUTO_EXPORT, STUBNAME );
SYS_LIB_EXPORT( _PS3_PPU_Project1_export_function, LIBNAME );

int console_write(const char * s)
{
uint32_t len;
system_call_4(403, 0, (uint64_t) s, 32, (uint64_t) &len);
return_to_user_prog(int);
}
void sleep(usecond_t time)
{
sys_timer_usleep(time * 1000);
}

sys_ppu_thread_t BLB_main;
sys_ppu_thread_t create_thread(void (*entry)(uint64_t), int priority, size_t stacksize, const char* threadname,sys_ppu_thread_t id)
{
if(sys_ppu_thread_create(&id, entry, 0, priority , stacksize, 0, threadname) == CELL_OK)
{
console_write("\n\nMENU STARTED !\n\n");
}

return id;
}

void writeString(const char* str, int len, unsigned int addr)
{
for(int i = 0; i < len; i++)
{
if(*(str+i) == 0x00) {break;;}
*(char*)(addr+i) = *(str+i);
}
}

void StartMenu(uint64_t nothing)
{

for(;Winky Winky
{
console_write("\nIt Works\n");
sleep(1000);
}
}

// An exported function is needed to generate the project's PRX stub export library
extern "C" int _PS3_PPU_Project1_export_function(void)
{
return CELL_OK;
}

extern "C" int _PS3_PPU_Project1_prx_entry(void)
{

create_thread(StartMenu, 0x4AA, 0x6000, "BLB Main", BLB_main);
return SYS_PRX_RESIDENT;
}



I found some functions that I wanted to use
You must login or register to view this content. 739307-small-c-ps3-library-source.html

but if I copy and paste these into prx.cpp, I get a lot of Undefines, like BYTE is Undefine, UINT32 is Undefine

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, 8 );
std::reverse(read, read + 8 );
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, 8 );
std::reverse(read, read + 8 );
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, 8 );
std::reverse(read, read + 8 );
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 + 8 );
SetMemory(Address, bytes, 8 );
}
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 + 8 );
SetMemory(Address, bytes, 8 );
}
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 + 8 );
SetMemory(Address, bytes, 8 );
}
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 == b)
CheckArray++;
return CheckArray == ArrayLength;
}
static std::string ReadString(UINT32 Address, INT32 Length)
{
return (reinterpret_cast<const char*>(GetMemory(Address, Length)));
}

My question is, how do I add these functions to the prx.cpp?
or if someone could sent me an empty sprx Project Source Code with those functions implemented then it would be great!
(adsbygoogle = window.adsbygoogle || []).push({});
10-06-2014, 04:04 AM #2
Me too,i also want to know how to add function in sprx.cpp
10-06-2014, 12:48 PM #3
Though I don't know but it looks like a very powerful way
10-06-2014, 11:21 PM #4
Ok bro this is a problem alot of people incounter but its actually really easy to fix all you need to do is

Goto: Project/The very bottom option/Configuration Properties/Linker/Additional Dependencies

Then press edit and then add this into it :
     
$(SCE_PS3_ROOT)\target\ppu\lib\libc.a
$(SCE_PS3_ROOT)\target\ppu\lib\libc_stub.a
$(SN_PS3_PATH)\ppu\lib\sn\libsn.a
$(SCE_PS3_ROOT)\target\ppu\lib\libm.a
$(SCE_PS3_ROOT)\target\ppu\lib\libio_stub.a


Then Press: Ok/Apply/Ok

Then your all done it wont give you that error i hope this helped you buddy Winky Winky
10-07-2014, 02:42 AM #5
Originally posted by optantic View Post
I downloaded the sprx Project Source code from BaSs HaXoR , it comes with prx.cpp and Builds fine


#include "stdafx.h"
#include <cellstatus.h>
#include <sys/prx.h>
#include <sys/timer.h>
#include <sys/syscall.h>
#include <sys/ppu_thread.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/memory.h>
#include <typeinfo>

SYS_MODULE_INFO( PS3_PPU_Project1, 0, 1, 1);
SYS_MODULE_START( _PS3_PPU_Project1_prx_entry );

SYS_LIB_DECLARE_WITH_STUB( LIBNAME, SYS_LIB_AUTO_EXPORT, STUBNAME );
SYS_LIB_EXPORT( _PS3_PPU_Project1_export_function, LIBNAME );

int console_write(const char * s)
{
uint32_t len;
system_call_4(403, 0, (uint64_t) s, 32, (uint64_t) &len);
return_to_user_prog(int);
}
void sleep(usecond_t time)
{
sys_timer_usleep(time * 1000);
}

sys_ppu_thread_t BLB_main;
sys_ppu_thread_t create_thread(void (*entry)(uint64_t), int priority, size_t stacksize, const char* threadname,sys_ppu_thread_t id)
{
if(sys_ppu_thread_create(&id, entry, 0, priority , stacksize, 0, threadname) == CELL_OK)
{
console_write("\n\nMENU STARTED !\n\n");
}

return id;
}

void writeString(const char* str, int len, unsigned int addr)
{
for(int i = 0; i < len; i++)
{
if(*(str+i) == 0x00) {break;;}
*(char*)(addr+i) = *(str+i);
}
}

void StartMenu(uint64_t nothing)
{

for(;Winky Winky
{
console_write("\nIt Works\n");
sleep(1000);
}
}

// An exported function is needed to generate the project's PRX stub export library
extern "C" int _PS3_PPU_Project1_export_function(void)
{
return CELL_OK;
}

extern "C" int _PS3_PPU_Project1_prx_entry(void)
{

create_thread(StartMenu, 0x4AA, 0x6000, "BLB Main", BLB_main);
return SYS_PRX_RESIDENT;
}



I found some functions that I wanted to use
You must login or register to view this content. 739307-small-c-ps3-library-source.html

but if I copy and paste these into prx.cpp, I get a lot of Undefines, like BYTE is Undefine, UINT32 is Undefine

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, 8 );
std::reverse(read, read + 8 );
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, 8 );
std::reverse(read, read + 8 );
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, 8 );
std::reverse(read, read + 8 );
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 + 8 );
SetMemory(Address, bytes, 8 );
}
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 + 8 );
SetMemory(Address, bytes, 8 );
}
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 + 8 );
SetMemory(Address, bytes, 8 );
}
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 == b)
CheckArray++;
return CheckArray == ArrayLength;
}
static std::string ReadString(UINT32 Address, INT32 Length)
{
return (reinterpret_cast<const char*>(GetMemory(Address, Length)));
}

My question is, how do I add these functions to the prx.cpp?
or if someone could sent me an empty sprx Project Source Code with those functions implemented then it would be great!

you've got this all wrong... all thoes functions are for tmapi (RTM/RTE) this is why i recommend learning things before you just jump into them. also a UINT32 = unsigned int so typedef unsigned int UINT32

The following user thanked milky4444 for this useful post:

10-07-2014, 02:45 AM #6
Originally posted by Connerg123 View Post
Ok bro this is a problem alot of people incounter but its actually really easy to fix all you need to do is

Goto: Project/The very bottom option/Configuration Properties/Linker/Additional Dependencies

Then press edit and then add this into it :
     
$(SCE_PS3_ROOT)\target\ppu\lib\libc.a
$(SCE_PS3_ROOT)\target\ppu\lib\libc_stub.a
$(SN_PS3_PATH)\ppu\lib\sn\libsn.a
$(SCE_PS3_ROOT)\target\ppu\lib\libm.a
$(SCE_PS3_ROOT)\target\ppu\lib\libio_stub.a


Then Press: Ok/Apply/Ok

Then your all done it wont give you that error i hope this helped you buddy Winky Winky


no that would not help at all unless he is using headers that use thoes libs
10-07-2014, 08:40 AM #7
optantic
Pokemon Trainer
Originally posted by milky4444 View Post
no that would help at all unless he is using headers that use thoes libs

Those libs are already in there
I have no knowledge of C lol, was following the How to make a sprx read/write memory tutorial and the " if (*(char*)0xaddr == xx) " part was working for me, so I wanted to try to use those ReadBYTE , WriteBYTE functions and failed
now, I try to use if(*(unsigned char*)0xaddr instead of just char and is all good now
Thanks


btw, does anyone has the coding for the InGame() function ?
"if(InGame( ) ) / Detects when its InGame so it knows when to run and not every have of a millisecond"
10-07-2014, 12:47 PM #8
Originally posted by milky4444 View Post
no that would not help at all unless he is using headers that use thoes libs


Aw yeah, I didnt read what functions he was using i just thought that this was the problem because it was with me, Good thing you pointed that out Winky Winky

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo