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);
}


Last edited by Shark ; 07-16-2014 at 10:47 AM.

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, Winter
07-20-2014, 04:29 PM #38
Originally posted by Shark View Post
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
no for(;Winky Winky loops are not good if you care about stability. my best bet would to do

bool GetOrigin[18] = {false};//Whenever you toggle this to true it will start getting your origin
void GetOriginNigga(short clientID){
while(GetOrigin[clientID]){
//Do Origin Shit Here
}
}
09-03-2014, 02:14 PM #39
BiBaBu
Keeper
Lol just want to know if i putted all right togehter lol Happy im new in c++ .... dont hate me lol thanks Snail ( i ask before i get some erros on my ps3 )

    
#include "stdafx.h"
#include <cellstatus.h>
#include <sys/prx.h>
#include <sys/sys_time.h>
#include <sys/syscall.h>
#include <sys/ppu_thread.h>
#include <string.h>
#include <sys/syscall.h>
#include <stdarg.h>
#include <stddef.h>
#include <sys/timer.h>

void sleep(usecond_t time)
{
sys_timer_usleep(time * 1000);
}

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);
}

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;
}

SYS_MODULE_INFO( Test, 0, 1, 1);
SYS_MODULE_START( _Test_prx_entry );

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

//GO

enum Buttons
{
Up = 0x3135,
Down = 0x3137,
Left = 0x3139,
Right = 0x3231,
X = 0x3235,
Square = 0x3131,
Triangle = 0x3430,
L1 = 0x3133,
L2 = 0x3700,
L3 = 0x3900,
R1 = 0x3100,
R2 = 0x3500,
R3 = 0x3237
};
bool DetectBtn(int clientIndex, Buttons Btn)
{
return *(short*)(*(int*)0x017BB210 + (clientIndex * 0x68B80) + 0x21022) == Btn;
}

//Buttons
{
if (InGame())
{
if(DetectBtn(0, Up))
{
//how do i put this together lol
}
}
}



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

}
extern "C" int _Test_prx_entry(void)
{
create_thread(thread_entry, 0x4AA, 0x6000, "Main_Thread");
return 0;
return SYS_PRX_RESIDENT;
}
05-05-2015, 01:41 PM #40
xiN3eemHD
Gym leader
hey guys im trying to make a sprx for a elf but im getting bad function address

any idea how to slove this?

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo