Post: SPRX C++ Code/Help Thread
07-16-2014, 07:23 AM #1
Shark
Retired.
(adsbygoogle = window.adsbygoogle || []).push({}); Hey, since the method to make sprx's has been released I thought I would make this thread where everyone can post their codes (if they want) and request help (nothing to stupid please...), so ill start it off with a few codes


Write/Read Memory

    
Int32
*(int*)OffsetToWriteTo = IntergerToWrite;
int mem = *(int*)OffsetToRead;

Float
*(float*)OffsetToWriteTo = FloatToWrite;
float mem = *(int*)OffsetToRead;

there is many more of these just google it or look at xbox :p



Get ProcessID

    
#include <sys/syscall.h>

sys_pid_t sys_process_getpid(void)
{
system_call_0(1);
return_to_user_prog(sys_pid_t);
}



Sleep

    
#include <sys/sys_time.h>

void sleep(second_t time)
{
sys_timer_sleep(time);
}


Exit Thread

    
#include <sys/syscall.h>

int sys_ppu_thread_exit()
{
system_call_1(41, 0);
return_to_user_prog(int);
}



Create Thread

    
#include <sys/syscall.h>
#include <sys/ppu_thread.h>

sys_ppu_thread_t id;
sys_ppu_thread_t create_thread(void (*entry)(uint64_t), int priority, size_t stacksize, const char* threadname)
{
if(sys_ppu_thread_create(&id, entry, 0, priority , stacksize, 0, threadname) != CELL_OK)
{
console_write("Thread creation failed\n");
}
else
{
console_write("Thread created\n");
}
return id;
}



Console Write

    
#include <string.h>
#include <sys/syscall.h>
#include <stdarg.h>
#include <stddef.h>

int console_write(const char * s)
{
uint32_t len;
system_call_4(403, 0, (uint64_t) s, std::strlen(s), (uint64_t) &len);
return_to_user_prog(int);
}


(adsbygoogle = window.adsbygoogle || []).push({});

The following 22 users say thank you to Shark for this useful post:

aburezk, Bad Luck Brian, elgolumm, flynhigh09, hackeveryone, HRX3, ImAzazel, iMoDz-Baptiste, ImPiffHD, KareraHekku, KranK, LaRip8, MegaMister, John, NotALegitPlayer, OLDSCHOOLMODZHD, RambosNGU, RouletteBoi, ShutTheCrunchUp, th3_goodGuy, Turk_Warrior, Hash847
07-18-2014, 03:52 AM #29
Turk_Warrior
League Champion
Originally posted by Sabotage View Post
When ever you brick a ps3, the problem is that most of the time it doesn't stay on. Its shuts off after 5 seconds, sometimes more but not enough for you to flash a dump. If you ever brick and your ps3 shuts off by it self, you need to solder a wire from the nor tristate to a GND point on the motherboard. That will force it to stay on for you to flash a good dump. Go to the wiki and look around, you will find more info there. Also if you ever brick PM me.


My PS3 has never been opened.. i wanna keep it that way for when i sell it 350 with e3 flasher..

my e3 flasher is Bit Broken..
07-18-2014, 05:27 AM #30
This might be a stupid question and I feel stupid that its not working but I have been trying for hours to get a thread to loop but as soon as the loop finishes any work the thread stops I tried adding a bool so when it wasn't doing work it would sleep but it still doesn't continue looping. Thanks to anyone who can help.
07-18-2014, 05:06 PM #31
Originally posted by OLDSCHOOLMODZHD View Post
This might be a stupid question and I feel stupid that its not working but I have been trying for hours to get a thread to loop but as soon as the loop finishes any work the thread stops I tried adding a bool so when it wasn't doing work it would sleep but it still doesn't continue looping. Thanks to anyone who can help.

I would use While(true), with an instance of bool == false. Then just run bool = true, when you want to turn it on.

ex.
    
void myboolon
{
mybool = true;
}

bool mybool = false;
while (mybool == true)
{
CODE HERE...
}

The following user thanked BaSs_HaXoR for this useful post:

OLDSCHOOLMODZHD
07-18-2014, 08:24 PM #32
Originally posted by HaXoR View Post
~snip~


you can also do
     
for(;Winky Winky
{
//work
}

I found out that if anything in your code is wrong it stops the thread. Smile
07-19-2014, 08:00 AM #33
ItsLollo1000
Little One
Originally posted by OLDSCHOOLMODZHD View Post
you can also do
     
for(;Winky Winky
{
//work
}

I found out that if anything in your code is wrong it stops the thread. Smile


Or while(true) Choco :P

The following user thanked ItsLollo1000 for this useful post:

OLDSCHOOLMODZHD
07-19-2014, 08:59 AM #34
Originally posted by ItsLollo1000 View Post
Or while(true) Choco :P


Or while(1) Woot wow aren't we h4x0rs or wut? Woot
07-19-2014, 09:02 AM #35
ItsLollo1000
Little One
Originally posted by BlackPanther View Post
Or while(1) Woot wow aren't we h4x0rs or wut? Woot


haha we are so 1337
07-19-2014, 07:17 PM #36
imma teach you guys how to optimise your code so your SPRX shit is more stable.
okie dokie here are the tips.

tip #1: whenever you guys on ps3 figure out how to do static bool (_cdecl *Dvar_GetBool)(int, bool, const char*) = (bool(*)(int,bool,const char*))Dvar_GetBoolOffsetHere; you create a new thread and you do for eg on xbox it would be

DWORD WINAPI EntryPoint(void*){
while(GetBool("cl_ingame")){
//So you would do your stuff here when the game is running.
}else{
//On PlayerLeave Shit Here
}
}
Tip #2: for gods sake stop using for(;Winky Winky and while(true) <- infinte loops, Use while loops. they are better imo
so for eg if i wanted something to loop for only in the game you do while(GetBool("cl_ingame"))

Tip #3: [This wont have any effect on stability but its called [CLEAN CODE!!!]] so i see how people do things like for eg if(TestBool == true)//This is retarded as you can save characters by doing if(TestBool) //Means The SAME THING as the == true. and if you want it false you do if(!TestBool). Understand it? i surely hope so

Tip #4: Structures are your best friend here! so use them as they handle data better. so for eg

struct TestShit{
bool MenuOpened;
int ScrollMenuMax;
} TestShit[18];

Thats all i can think of atm. oh another thing. DO NOT DECLARE VARIABLES OUTSIDE THE SCOPE UNLESS ITS ABSOLUTELY NECESSARY! so for eg

[ATTACH=CONFIG]32646[/ATTACH]
see how its outside the Scope? this is a big nono. so thats about it Smile hope you take this into consideration :fa:

The following 2 users say thank you to MaybeEthernet for this useful post:

John, Shark
07-20-2014, 02:05 AM #37
Shark
Retired.
Originally posted by MaybeEthernet View Post
imma teach you guys how to optimise your code so your SPRX shit is more stable.
okie dokie here are the tips.

tip #1: whenever you guys on ps3 figure out how to do static bool (_cdecl *Dvar_GetBool)(int, bool, const char*) = (bool(*)(int,bool,const char*))Dvar_GetBoolOffsetHere; you create a new thread and you do for eg on xbox it would be

DWORD WINAPI EntryPoint(void*){
while(GetBool("cl_ingame")){
//So you would do your stuff here when the game is running.
}else{
//On PlayerLeave Shit Here
}
}
Tip #2: for gods sake stop using for(;Winky Winky and while(true) <- infinte loops, Use while loops. they are better imo
so for eg if i wanted something to loop for only in the game you do while(GetBool("cl_ingame"))

Tip #3: [This wont have any effect on stability but its called [CLEAN CODE!!!]] so i see how people do things like for eg if(TestBool == true)//This is retarded as you can save characters by doing if(TestBool) //Means The SAME THING as the == true. and if you want it false you do if(!TestBool). Understand it? i surely hope so

Tip #4: Structures are your best friend here! so use them as they handle data better. so for eg

struct TestShit{
bool MenuOpened;
int ScrollMenuMax;
} TestShit[18];

Thats all i can think of atm. oh another thing. DO NOT DECLARE VARIABLES OUTSIDE THE SCOPE UNLESS ITS ABSOLUTELY NECESSARY! so for eg

[ATTACH=CONFIG]32646[/ATTACH]
see how its outside the Scope? this is a big nono. so thats about it Smile hope you take this into consideration :fa:


puttng things outside a scope is neccesary if you make a function that returns something from its own scope to another function that isn't in the scope, if you do this it wont return anything as I experienced when trying to make a function to get my players origin :P, and there is nothing wrong with for(;Winky Winky loops imo but good post ethernet Smile

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo