Skip to content
forked from hitodama/libps4

Libc, POSIX and SCE module library for the PS4

License

Notifications You must be signed in to change notification settings

Mistawes/libps4

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libps4

Lbc, posix and sce module library for the ps4, generated by libps4-generator using libps4-std-include, libps4-sce-include and libps4-boilerplate

##Description

The libps4 is a generated (otherwise read-only) repository which can be cloned to build libps4.

This is an initial commit which provides roughly 1300 (mostly libc and posix) functions and the corresponding headers. It also includes the initial findings by the community (CTurt et al.) towards SCE modules.

If you are interrested in contributing to or seek more infos towards libps4, please see libps4-generator, libps4-std-include, libps4-sce-include and libps4-boilerplate for more. Feedback or help is very welcome. Don't consider the repos to stable though. Esp. over the next week.

##Internals, Hints and Warnings

###Global variables Be aware that global variables need to be manually managed (for now). This makes sense, once you consider that we can't stub them well (intercept access to them) and that we are (currently) running in a process which has these variables allocated somewhere in memory. As they are globals though, they are exposed as symbols.

When you use certain functions the compiler may complain that extern varables such as __isthreaded are undefined since they are not generated by the library. The way to resolve this is to declare all varables as int in your source and then try to recompile. The compiler will now note that the types of non int globals are missmatched. Since it will tell you the types, you can now adapt them acordingly (alternatively you may use __typeof__). Now your code compiles, but the variables will not be in sync'd with their global (host process) counterpart values. You will need to resolve the global versions manually, by using sceKernelDlsym to get the address of the variable, and then retrieve the value as needed. In essence you need to understand, when and if these variables change and refresh them from the address accordingly (before and after any accessing functions would be preferable ... however may are more or less constant and need no further management).

int __isthreaded;
int *__isthreaded_addr; /*don't use postfix p as it may collide with std vars (not the case with __isthreaded)*/

int64_t _main(void)
{
  int libc = sceKernelLoadStartModule("libSceLibcInternal.sprx", 0, NULL, 0, 0, 0);
  sceKernelDlsym(libc, "__isthreaded", (void **)&__isthreaded_addr);

  /* refresh value */
  __isthreaded = *__isthreaded_addr; 

This should be addressed further and be suppoorted better by standardized macros asap. At best we may be able to auto-resolve them, but that will probably not be in the nearest of futures.

#Todo

  • Extend readme

About

Libc, POSIX and SCE module library for the PS4

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.2%
  • C++ 1.5%
  • Makefile 1.2%
  • Other 0.1%