Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Help getting started with making plugins :d
- https://playstationhax.xyz/forums/topic/1382-help-getting-started-with-making-plugins-d/
- Help getting started with making plugins :d
- Asked by Lucif3r
- noob
- ambitious
- rubbish
- gtfo
- Question
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 17, 2015
- So, I fell and hit my head and thought it would be a BRILLIANT idea to learn a bit about plugins, prx ones specifically.
- After a few days frustration and reading I finally got my environment set up and got it to build shit. Yay.
- However, I am at a loss now... While the sprx builds just fine, it freezes the console either during load, or shortly after returning to XMB(I load it with PRXLoader). Even sony's own rubbish examples freezes.
- Target Manager shits out a constant spam of "System Warning: Busy loop detected", and this is were I get confused... My sprx doesnt contain a loop anywhere. :/
- I am obviously missing something here, probably simple as hell...
- So, heres the code that freezes during load:
- #include <sys/prx.h>
- SYS_MODULE_INFO( shityPRX, 0, 1, 0 );
- SYS_MODULE_START( _start );
- SYS_MODULE_STOP( _stop );
- int _start(void);
- int _stop(void);
- int _start(void)
- {
- return SYS_PRX_RESIDENT;
- }
- int _stop(void)
- {
- return SYS_PRX_STOP_OK;
- }
- And by blatantly stealing Mysis' ppu_thread_create function from his recording plugin, and adding the following;
- void thread_entry(uint64_t arg)
- {
- sys_timer_sleep(10);
- }
- the plugin loads fine, but freezes shortly after returning to xmb(I assume just about when sleep(x) runs out).
- This leads me to believe the plugin freezes the console when it has nothing to do? However, I am no where near knowledgeable enough to actually understand why it does that or how to fix it.
- Mysis got a while(true) loop inside his thread_entry, which confuses me even more.. Ive been taught that a while(true) loop is the best way to crash or freeze your program lol. Im sure its theres a reason for it to be there, but I fail to see it :(
- Ive never claimed to be a good coder, quite the opposite in fact. Ive only coded in C# before, so not only am I switching from winblows programs to ps3 plugins, I am also switching from C# to C++ lol...
- Unfortunately C#/windows does a lot automatically, such as handling the 'idling' of a program, which doesnt really help me fixing this issue...
- Could it be as easy as just adding an empty while(true) loop within the thread_entry with a small delay(sys_timer_sleep(1) or something) to keep the plugin from freezing the PS3?
- If someone could spare 10sec of their life to laugh at me and point out the obvious I'd appreciate it :) Kinda embarrassing to get stuck this early... :(
- Upvote 2
- TheDarkprogramer and 3141card reacted to this
- SORT BY VOTES
- SORT BY DATE
- 1 2 3 NEXT Page 1 of 3
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 17, 2015 (edited)
- #include <sys/prx.h>
- #include <sys/ppu_thread.h>
- #include <sys/syscall.h> // for syscall usage
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- SYS_MODULE_INFO(TESTPLUGIN, 0, 1, 0); // plugin info
- SYS_MODULE_START(testplugin_start); // plugin start function
- SYS_MODULE_STOP(testplugin_stop); // plugin stop function
- // thread names, optional and here over macros, names are usefull for debug
- #define THREAD_NAME "testplugin_thread"
- #define STOP_THREAD_NAME "testplugin_stop_thread"
- // global variables
- static sys_ppu_thread_t thread_id = -1;
- // functions prototypes
- int testplugin_start(uint64_t arg);
- int testplugin_stop(void);
- // exit over syscall or crash
- static inline void _sys_ppu_thread_exit(uint64_t val)
- {
- system_call_1(41, val);
- }
- static inline sys_prx_id_t prx_get_module_id_by_address(void *addr)
- {
- system_call_1(461, (uint64_t)(uint32_t)addr);
- return (int)p1;
- }
- // plugin main ppu thread, like main in normal c prog
- static void testplugin_thread(uint64_t arg)
- {
- // do work...
- sys_ppu_thread_exit(0); // here ends the plugin. like return(0); on main end in c
- }
- // plugin start function, start our main ppu thread...
- int testplugin_start(uint64_t arg)
- {
- sys_ppu_thread_create(&thread_id, testplugin_thread, 0, 3000, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, THREAD_NAME);
- // Exit thread using directly the syscall and not the user mode library or we will crash
- _sys_ppu_thread_exit(0);
- return SYS_PRX_RESIDENT;
- }
- // plugin exit function, proper stop our plugin
- static void testplugin_stop_thread(uint64_t arg)
- {
- done = 1;
- if (thread_id != (sys_ppu_thread_t)-1)
- {
- uint64_t exit_code;
- sys_ppu_thread_join(thread_id, &exit_code);
- }
- sys_ppu_thread_exit(0);
- }
- static void finalize_module(void)
- {
- uint64_t meminfo[5];
- sys_prx_id_t prx = prx_get_module_id_by_address(finalize_module);
- meminfo[0] = 0x28;
- meminfo[1] = 2;
- meminfo[3] = 0;
- system_call_3(482, prx, 0, (uint64_t)(uint32_t)meminfo);
- }
- int testplugin_stop(void)
- {
- sys_ppu_thread_t t;
- uint64_t exit_code;
- sys_ppu_thread_create(&t, testplugin_stop_thread, 0, 0, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, STOP_THREAD_NAME);
- sys_ppu_thread_join(t, &exit_code);
- finalize_module();
- _sys_ppu_thread_exit(0);
- return SYS_PRX_STOP_OK;
- }
- Based on the cobra test plugin.
- EDIT: this is for C, (I like smal plugins).
- Use User's test plugin(into PRXLoader download) for VS and C++.
- #include <cellstatus.h>
- #include <sys/prx.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- SYS_MODULE_INFO( test_prx, 0, 1, 1);
- SYS_MODULE_START( _test_prx_prx_entry );
- SYS_LIB_DECLARE( cellPrx_test_prx, SYS_LIB_AUTO_EXPORT );
- SYS_LIB_EXPORT( _test_prx_export_function, cellPrx_test_prx );
- void ppu_thread_exit()
- {
- system_call_1(41, 0); //ppu_thread_exit
- }
- // An exported function is needed to generate the project's PRX stub export library
- extern "C" int _test_prx_export_function(void)
- {
- return CELL_OK;
- }
- extern "C" int _test_prx_prx_entry(void)
- {
- char test[] = "Hello VSH\n";
- uint32_t len;
- system_call_4(403, 0, (uint64_t) test, strlen(test), (uint64_t) &len); //tty write
- ppu_thread_exit();
- return SYS_PRX_RESIDENT;
- }
- Edited February 18, 2015 by 3141card
- Upvote 2
- TheDarkprogramer and mysis reacted to this
- 0
- TheDarkprogramer
- PlayStationHaX Guru
- TheDarkprogramer
- Developer
- Founding Member
- V.I.P
- 848
- 1,215 posts
- Location: Somewhere In South Africa
- Posted February 18, 2015
- Nice read means I can learn alot too as im also stuggeling switching to object c /c++
- As u said windows c# handels alot and I mean alot of the heavy work so working with this would help me a lot ... alao did you setup with linex or did you use visual studios with sony sdk ? This saved me alot of time a while back when I was playing around
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 18, 2015 (edited)
- I use mostly cygwin under win7, here I have my old psl1ght. The "other SDK" cell dir is copyed to
- cygwin/usr/local.
- psl1ght and "other SDK" together without trouble.
- I code only in C and compile in cygwin console, my editor for writing source code is Geany.
- I have VS2010 too(some samples need VS, not many), but don't like it.
- Edited February 18, 2015 by 3141card
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 18, 2015
- On 2/17/2015 at 11:37 PM, 3141card said:
- Based on the cobra test plugin.
- EDIT: this is for C, (I like smal plugins).
- Use User's test plugin(into PRXLoader download) for VS and C++.
- Are those 2 examples supposed to compile properly on their own? Because...
- First example:
- 1>------ Rebuild All started: Project: mooo, Configuration: Debug PS3 ------
- 1> cobra.cpp
- 1>cobra.cpp(21,36): warning 68: integer conversion resulted in a change of sign
- 1>
- 1>cobra.cpp(79,49): warning 1628: argument of type "void (*)()" is incompatible with parameter (1 of prx_get_module_id_by_address) of type "void *"
- 1>
- 1>cobra.cpp(22,11): warning 552: variable "done" was set but never used <--- what? It is used!
- 1>
- 1> ppu-lv2-prx-libgen.exe: "module_start(=testplugin_start)" is undefine symbol. can't export.
- 1> ps3ppuld 370.1.4467.0 (rel,TR,1.3_995_370,src @112234 #451087 ) "F:\SCE\370\host-win32\sn\bin\ps3ppuld.exe"
- 1>Command line : error : L0303: error generating PRX (prx-libgen failed)
- 1>Command line : error : L0064: Linking aborted
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- second:
- 1>------ Rebuild All started: Project: mooo, Configuration: Debug PS3 ------
- 1> cobra.cpp
- 1> undefined reference to `memcpy'
- 1> undefined reference to `strlen'
- 1> ps3ppuld 370.1.4467.0 (rel,TR,1.3_995_370,src @112234 #451087 ) "F:\SCE\370\host-win32\sn\bin\ps3ppuld.exe"
- 1>Command line : error : L0303: error generating PRX (prx-fixup failed)
- 1>Command line : error : L0064: Linking aborted
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- :(
- Im using VSC2010 with the sony 3.70(because the 4.0 refuses to work) SDK and VS plugin.
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 18, 2015
- 1. is not for VS, you need a makefile...
- 2. you need the full project, look for the test_prx folder in PRXLoader download.
- open the test_prx.sln with VS. Here are e.g. libc.c missing for `memcpy' and `strlen'.
- Upvote 1
- Lucif3r reacted to this
- 0
- Frankie
- Member
- Frankie
- Regular Member
- 2
- 14 posts
- Posted February 18, 2015
- On 2/17/2015 at 11:37 PM, 3141card said:
- #include <sys/prx.h>
- #include <sys/ppu_thread.h>
- #include <sys/syscall.h> // for syscall usage
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- SYS_MODULE_INFO(TESTPLUGIN, 0, 1, 0); // plugin info
- SYS_MODULE_START(testplugin_start); // plugin start function
- SYS_MODULE_STOP(testplugin_stop); // plugin stop function
- // thread names, optional and here over macros, names are usefull for debug
- #define THREAD_NAME "testplugin_thread"
- #define STOP_THREAD_NAME "testplugin_stop_thread"
- // global variables
- static sys_ppu_thread_t thread_id = -1;
- // functions prototypes
- int testplugin_start(uint64_t arg);
- int testplugin_stop(void);
- // exit over syscall or crash
- static inline void _sys_ppu_thread_exit(uint64_t val)
- {
- system_call_1(41, val);
- }
- static inline sys_prx_id_t prx_get_module_id_by_address(void *addr)
- {
- system_call_1(461, (uint64_t)(uint32_t)addr);
- return (int)p1;
- }
- // plugin main ppu thread, like main in normal c prog
- static void testplugin_thread(uint64_t arg)
- {
- // do work...
- sys_ppu_thread_exit(0); // here ends the plugin. like return(0); on main end in c
- }
- // plugin start function, start our main ppu thread...
- int testplugin_start(uint64_t arg)
- {
- sys_ppu_thread_create(&thread_id, testplugin_thread, 0, 3000, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, THREAD_NAME);
- // Exit thread using directly the syscall and not the user mode library or we will crash
- _sys_ppu_thread_exit(0);
- return SYS_PRX_RESIDENT;
- }
- // plugin exit function, proper stop our plugin
- static void testplugin_stop_thread(uint64_t arg)
- {
- done = 1;
- if (thread_id != (sys_ppu_thread_t)-1)
- {
- uint64_t exit_code;
- sys_ppu_thread_join(thread_id, &exit_code);
- }
- sys_ppu_thread_exit(0);
- }
- static void finalize_module(void)
- {
- uint64_t meminfo[5];
- sys_prx_id_t prx = prx_get_module_id_by_address(finalize_module);
- meminfo[0] = 0x28;
- meminfo[1] = 2;
- meminfo[3] = 0;
- system_call_3(482, prx, 0, (uint64_t)(uint32_t)meminfo);
- }
- int testplugin_stop(void)
- {
- sys_ppu_thread_t t;
- uint64_t exit_code;
- sys_ppu_thread_create(&t, testplugin_stop_thread, 0, 0, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, STOP_THREAD_NAME);
- sys_ppu_thread_join(t, &exit_code);
- finalize_module();
- _sys_ppu_thread_exit(0);
- return SYS_PRX_STOP_OK;
- }
- Based on the cobra test plugin.
- EDIT: this is for C, (I like smal plugins).
- Use User's test plugin(into PRXLoader download) for VS and C++.
- #include <cellstatus.h>
- #include <sys/prx.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- SYS_MODULE_INFO( test_prx, 0, 1, 1);
- SYS_MODULE_START( _test_prx_prx_entry );
- SYS_LIB_DECLARE( cellPrx_test_prx, SYS_LIB_AUTO_EXPORT );
- SYS_LIB_EXPORT( _test_prx_export_function, cellPrx_test_prx );
- void ppu_thread_exit()
- {
- system_call_1(41, 0); //ppu_thread_exit
- }
- // An exported function is needed to generate the project's PRX stub export library
- extern "C" int _test_prx_export_function(void)
- {
- return CELL_OK;
- }
- extern "C" int _test_prx_prx_entry(void)
- {
- char test[] = "Hello VSH\n";
- uint32_t len;
- system_call_4(403, 0, (uint64_t) test, strlen(test), (uint64_t) &len); //tty write
- ppu_thread_exit();
- return SYS_PRX_RESIDENT;
- }
- Do you know the syscall or command for disabling the process in TM so no one can view memory to edit it?
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 18, 2015
- No, and I work not with DEX, I use only rebug 4.46 CEX(to lazy to update on last rebug), therefor no TM, sry.
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 18, 2015
- On 2/18/2015 at 12:55 AM, 3141card said:
- 1. is not for VS, you need a makefile...
- 2. you need the full project, look for the test_prx folder in PRXLoader download.
- open the test_prx.sln with VS. Here are e.g. libc.c missing for `memcpy' and `strlen'.
- ahh I see. Yea adding that libc got rid of those 2 errors and it compiled fine, and runs fine on the ps3 as well... However, that doesnt bring me any closer to understanding why the PS3 freezes/"busy loops" with the code I included in my first post...
- Man, I have a lot to learn :P
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 18, 2015 (edited)
- #include <cellstatus.h>
- #include <sys/prx.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- SYS_MODULE_INFO( test_prx, 0, 1, 1);
- SYS_MODULE_START( _test_prx_prx_entry );
- SYS_LIB_DECLARE( cellPrx_test_prx, SYS_LIB_AUTO_EXPORT );
- SYS_LIB_EXPORT( _test_prx_export_function, cellPrx_test_prx );
- void ppu_thread_exit()
- {
- system_call_1(41, 0); //ppu_thread_exit
- }
- // An exported function is needed to generate the project's PRX stub export library
- extern "C" int _test_prx_export_function(void)
- {
- return CELL_OK;
- }
- extern "C" int _test_prx_prx_entry(void)
- {
- // do work... e.g. your sleep
- ppu_thread_exit();
- return SYS_PRX_RESIDENT;
- }
- This is, at bottom, the prototype you have to use for start your own projects.
- EDIT:
- Look also on mysis plugins, you can learn a lot from this :)
- Edited February 18, 2015 by 3141card
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 18, 2015
- I... see... So a lack of a simple ppu_thread_exit() was the cause of all this frustration... I knew it was simple -.-...
- Plugin compiles and loads fine now, and I even added a function that worked!
- Although I have (already lol) run into a new, weird, issue.
- This is a sample to demonstrate the errors:
- extern "C" int dbprint(char * text) //<- line 123
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- return true; //<- line 128
- }
- -------------------------------------------------------
- 1>prx.c(123,7): error 40: expected an identifier
- 1>
- 1>prx.c(123,7): error 261-D: explicit type is missing ("int" assumed)
- 1>
- 1>prx.c(128,8): error 20: identifier "true" is undefined
- 1>
- 1>prx.c(207,1): warning 224: function "dbprint" declared implicitly <--- A call to the above function.
- Ok so, as you can see it doesnt accept "extern "C" ... ", and somehow it even complains that "true" is undefined.
- It doesnt matter where I put "extern "C" " or "true", so its not function-specific, and they are independent of eachother. It also whines about "bool" and "false", and god knows what else.
- Ive compared my code and headers with both the test_prx and mysis' rec_plugin, and neither of those has a header that I do not. Ive also compared the output/compiler, and they are the same settings... And yes, both mysis' and test_prx finds "true" and "extern "C" " etc just fine...
- My dbprint function works just fine btw, if I remove the extern "C" and "true"(which I added for demonstration).
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 18, 2015
- extern "C" say the compiler that the code must be compiled with C compiler, in C there is no boolean per default,
- to use bool in C I must include stdbool.h or define it self. -> http://stackoverflow.com/questions/1921539/using-boolean-values-in-c
- The function dbprint() is of type int, therefor she must return a int like return 0;. If you not make error checks, you need no return,
- than you can even use void dbprint().
- btw, you are on the right way :) play with the code, source of other plugins and you learn it fast.
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 18, 2015
- Mmm, not sure you got what I meant, the errors are independant of each other.
- I'll give you 2 more examples:
- int dbprint(char * text)
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- while(true)
- {
- //dostuff
- }
- }
- ------------------------------
- 1> libc.c
- 1> prx.c
- 1>prx.c(128,7): error 20: identifier "true" is undefined
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- extern "C" int dbprint(char * text)
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- }
- ------------------------------------------
- 1> libc.c
- 1> prx.c
- 1>prx.c(123,7): error 40: expected an identifier
- 1>
- 1>prx.c(123,7): error 261-D: explicit type is missing ("int" assumed)
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- int dbprint(char * text)
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- }
- -------------------------------------------
- ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
- And this is regardless of function, if both true/bool/etc and external "C" are present or not.
- In fact, I'll throw in another example too. Just a normal definition, outside of any function:
- bool exit_thread=false;
- sys_prx_id_t prx_id;
- sys_prx_module_info_t *pInfo;
- --------------------------------
- 1> libc.c
- 1> prx.c
- 1>prx.c(95): error 20: identifier "bool" is undefined
- 1>
- 1>prx.c(95,17): error 20: identifier "false" is undefined
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- edit: Well, heres an example from test_prx that I just added a while(true) loop in:
- extern "C" int _test_prx_prx_entry(void)
- {
- while(true)
- {
- //wasd
- }
- char test[] = "Hello VSH\n";
- uint32_t len;
- system_call_4(403, 0, (uint64_t) test, strlen(test), (uint64_t) &len); //tty write
- ppu_thread_exit();
- return SYS_PRX_RESIDENT;
- }
- -----------------------------
- ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
- And yeah, as I said, I have the same #include's in my code as test_prx have(incl. libc.c/libc.h)...
- And heres the exact same thing in MY entry:
- extern "C" int _prx_start(void)
- {
- while(true)
- {
- //fail
- }
- ppu_thread_exit();
- return SYS_PRX_RESIDENT;
- }
- -------------------
- 1> libc.c
- 1> prx.c
- 1>prx.c(130,7): error 40: expected an identifier
- 1>
- 1>prx.c(130,7): error 261-D: explicit type is missing ("int" assumed)
- 1>
- 1>prx.c(132,7): error 20: identifier "true" is undefined
- 1>
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 18, 2015
- LOL, now I see, you have renamed prx.cpp to prx.c, a .c file is C code, the extern C is useless,
- and bool is not available per default into C.
- I think you would code in C++ like mysis ? Than you must use extern "C" for using C stuff.
- to tell the compiler what into your C++ code is C code.
- int dbprint(char * text) // a function into a C file, ok
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- while(true) // true is bool, not per defaut in C -> error 20: undefined
- {
- //dostuff
- }
- // return an int; is also missing
- }
- ------------------------------
- 1> libc.c
- 1> prx.c
- 1>prx.c(128,7): error 20: identifier "true" is undefined
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- extern "C" int dbprint(char * text) // no extern C, you are in C
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- // return missing too
- }
- ------------------------------------------
- 1> libc.c
- 1> prx.c
- 1>prx.c(123,7): error 40: expected an identifier
- 1>
- 1>prx.c(123,7): error 261-D: explicit type is missing ("int" assumed)
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- int dbprint(char * text)
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- // return an int missing, no error in VS ?
- }
- -------------------------------------------
- ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 18, 2015
- On 2/18/2015 at 5:37 AM, 3141card said:
- LOL, now I see, you have renamed prx.cpp to prx.c, a .c file is C code, the extern C is useless,
- and bool is not available per default into C.
- ......................................................... *renames*
- extern "C" int _prx_start(void)
- {
- while(true)
- {
- //work?
- }
- ppu_thread_exit();
- return SYS_PRX_RESIDENT;
- }
- --------------------------------
- 1> libc.c
- 1> prx.cpp
- 1>prx.cpp(128): warning 942: missing return statement at end of non-void function "dbprint" <-- that answer your question :P? I am aware of that :), it whines, but compiles and works fine, I am obviously adding a return now though :)
- ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
- ...... Im an idiot... lol... How the hell could I have missed that... Thanks a lot :D
- Upvote 1
- 3141card reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 18, 2015
- ...
- #include <cell/sysmodule.h>
- void loadStuff(void)
- {
- int32_t ret;
- ret = cellSysmoduleLoadModule( CELL_SYSMODULE_IO );
- //a few more calls
- }
- ---------------------------------------
- 1> undefined reference to `cellSysmoduleLoadModule' <-- one for each call
- 1>Command line : error : L0303: error generating PRX (prx-fixup failed)
- 1>Command line : error : L0064: Linking aborted
- ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
- sysmodule.h
- /* function prototypes */
- int cellSysmoduleLoadModule(uint16_t id);
- using 'extern "C" ' for the loadStuff function doesnt change a thing...
- 56331217.jpg
- Upvote 1
- zecoxao reacted to this
- 0
- zecoxao
- Posting Freak
- zecoxao
- Super Admin
- Founding Member
- Scene Contributor
- V.I.P
- 1,348
- 882 posts
- Posted February 18, 2015 (edited)
- On 2/18/2015 at 7:28 AM, Lucif3r said:
- snip
- you need to link the library (-l<name of library) in the Makefile
- 1>Command line : error : L0064: Linking aborted Edited February 18, 2015 by zecoxao
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 18, 2015
- On 2/18/2015 at 7:43 AM, zecoxao said:
- you need to link the library (-l<name of library) in the Makefile
- lol... Thanks, that fixed it. Weird though, you'd imagine VS would add that automatically... Or maybe Im just too spoiled by C# lol.
- Alright, time to take a break from this, theres only so much info I can take in each day lol. Thanks for all the help so far :) Im sure I'll be back with more lol :smashing-computer:
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 18, 2015
- Its ok patrick, no need for loading the io module, it is already loaded by vsh. Notice, your plugin is only a thread into
- the vsh process, things like network, io, fs, ... are loaded and running.
- If you would use a pad, look at mysis plugin.
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 19, 2015
- Aaand Im stuck again... Similar issue as the last one, except I cant seem to find a fix for this...
- This time its printf(and sprintf) that gives me "undefined reference to `printf'". This reference is located in stdio.h, and is included properly, and libio_stub.a is included in the 'make' argument...
- I also tried stealing mysis' vsh_sprintf function, incl his * getNIDfunc function. That one gives me "undefined reference to `strncmp'", which is located in string.h, which is included in the project...
- Ugh... Im getting sick of all these undefined references that are referenced already lol...
- 0
- Frankie
- Member
- Frankie
- Regular Member
- 2
- 14 posts
- Posted February 19, 2015
- On 2/19/2015 at 2:29 PM, Lucif3r said:
- Aaand Im stuck again... Similar issue as the last one, except I cant seem to find a fix for this...
- This time its printf(and sprintf) that gives me "undefined reference to `printf'". This reference is located in stdio.h, and is included properly, and libio_stub.a is included in the 'make' argument...
- I also tried stealing mysis' vsh_sprintf function, incl his * getNIDfunc function. That one gives me "undefined reference to `strncmp'", which is located in string.h, which is included in the project...
- Ugh... Im getting sick of all these undefined references that are referenced already lol...
- #define TOC 0x12345678
- struct opd_s
- {
- uint32_t sub;
- uint32_t toc;
- };
- opd_s printf_stub = { 0x12345678, TOC };
- int(*printf)(const char * format, ...) = (int(*)(const char*, ...))&printf_stub;
- You could always do this.
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 19, 2015
- Yeah, if only...
- 1>prx.cpp(278,5): error 102: "printf" has already been declared in the current scope
- 1>
- 1>prx.cpp(278,5): error 160: declaration is incompatible with previous "std::printf" (declared at line 143 of "$(SCE_PS3_ROOT)\target\ppu\include\stdio.h")
- time to borrow mr.dutch's wall.... :bash_head:
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 20, 2015
- libio_stub.a has nothing to do with stdio.h or C, its the PS3 IO library, -> pad, mouse, keyboard, remote control, ....
- I try to use the stub libs (I create for vsh exports) in VS project, works fine:
- http://www.mediafire.com/download/dtahiqronu1nk2d/test_plugin.rar
- I hate VS and to work with it, I include only 3 libs for test, If you would add the rest:
- Into the export headers you have C functions, so you must use extern "C"
- or you get name mangling trouble. Regarding classes, look at mysis code.
- Using this export libs is the most comfortable way to use vsh exports, if you need
- e.g. printf(), simply use it. :)
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 20, 2015
- Ok, I got it to work... However I didnt actually learn anything :( Except libio_stub has nothing to do with it lol, and I should include headers with #include "header.h" and not #include <header.h>(<- thats just for external dependencies if I understood it correctly?)
- But why did this work, and not the normal stdio definition? How can I learn when I need to apply special witchcraft and when not? Any references available so I can learn to make this witchcraft( :P)?
- I have been looking a lot at mysis plugins, or well, his record plugin... But when he starts with gibberish like "(void*&)(vshmain_981D7E9F) = (void*)((int)getNIDfunc("vshmain",0x981D7E9F));", thats when I crawl into a corner and weep lol. I understand (somewhat) what it does, but I dont understand how you find out you should use e.g "981D7E9F" and whatelse. or how to "translate" it to "words". I have no problems understanding stuff like "rec_interface = (rec_plugin_interface *)plugin_GetInterface(View_Find("rec_plugin"),1);", but all those random numbers..... lol
- I think Ive bitten off more than I can chew :/
- Thanks for all your help by the way, really appreciate it :)
- edit: actually, you could help me with one more thing if you want. :)
- It seems I misunderstood what s/printf did. What Im looking for is a way to output messages to the console in TM(sprintf actually did that, but not on request, it outputted a while after the call, seemingly random).
- I have one, "system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len);", but I cant seem to get it working similar as "sprintf("moo %02x", randomint)", it only accepts a single string/chararray, and ignores the ",randomint" arg(meaning the output is literally "moo %02x").
- Upvote 1
- 3141card reacted to this
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 20, 2015
- #include <header.h> its a standard header into systemdir, if you write e.g. a own -> #include "header.h".
- Quote
- But why did this work,...
- this prx coding is not like normal coding, again, the plugin main thread is only a thread into the vsh process of ps3.
- There is no way for use e.g. standard C things like memset(). But the vsh proc export many functions, and
- we can use this exports.
- Quote
- (void*&)(vshmain_981D7E9F) = (void*)((int)getNIDfunc("vshmain",0x981D7E9F));",
- Its a functions pointer, an addr into vsh code where the code of an function (e.g. one of the exports) starts.
- mysis getNIDfunc() get this addr by module name ("vshmain") and node-id (0x981D7E9F).
- If you call this addr with the proper args, this code/function will be exec.
- Quote
- ..., but I dont understand how you find out you should use e.g "981D7E9F"...
- I use e.g. the old IDA scripts from kakaroto, this scripts identify a many, the rest must be disassembled, e.g. by mysis.
- http://www.psdevwiki.com/ps3/VSH#Exports
- A many gcm functions was easy to identify by method codes. Syscalls, error-codes and strings are allways helpfull.
- The rest is simply reversing, its like a puzzle, thats fun.
- The plugin stuff is maybe not the best start into a new lang, :) And yes, names are better than nid's.
- Upvote 3
- Lucif3r, mysis and zecoxao reacted to this
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 20, 2015
- char msg[128]; // a string buffer
- int val = 666;
- sprintf(msg, // buffer to hold the result
- "number %d", // string format
- val); // var
- http://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 20, 2015
- Yes, I know that already :).
- I fixed it all by myself(!!!) though. The issue was it couldnt handle its job alongside tty_write. Removing all simultaneous tty_write calls improved it alot.
- However its still not perfect, I got the output in the while(true) loop, with a somewhat long(3sec) delay between each loop to not get spammed to death. However it stops working after 6-7 loops. Is there some kind of buffer thats not getting erased that I need to manually erase after each printf or something?
- Worth pointing out is that tty_write can keep spamming the console forever with a 100ms delay between each loop...
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 20, 2015
- Its bad to say something without to see the code.
- Give out msg's only if something is hapen, and not continously into a while-loop
- The memory you have into your plugin thread is = the stack size of your plugin main thread.
- if you need more, for whatever, use sys_memory_allocate() ...
- If you have e.g. char msg[128]; into your main, than yes, without freeing, your stack memory runs out.
- put such things never into a while loop. You need only one string buffer to hold you msg, not each round
- a new.
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- Mmm, heres a snippet of the code.
- while(true)
- {
- sys_timer_usleep(2000); //tried different delays
- if(cellPadGetData(0, &data) == CELL_PAD_OK && data.len > 0)
- {
- if(data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] > 0)// & CELL_PAD_CTRL_R2)
- {
- //printf("moo %02d ", data.button[CELL_PAD_BTN_OFFSET_PRESS_R2]);
- sys_timer_usleep(100); //tried different delays here as well
- dbprint("char test ");
- //printf("char test1 ");
- }
- }
- }
- the above code, with dbprint (tty_write), can spam the console(TM's console) forever when holding R2, even if I completely remove the first delay and only keep the 100ms delay(I have not tried to go lower, why would I lol).
- Replacing dbprint("char test ") with printf("char test1 "), regardless of delay(I tried up to a total of 5sec), and it stops printing after 4-7 loops. Using both dbprint and printf at the same time pretty much causes printf to not not print anything at all, while dbprint still prints(not exactly an issue, kinda makes sense when I think about it).
- printf("moo %02d", ...) behaves exactly the same as printf("char test1 "), so its not related to the reading of the button-data. The few times it prints, even printf("moo %02d", ...) works as expected.
- Since Im not actually using char x[x];, and instead pass the string directly in printf, I shouldnt be filling any buffer... At least not on purpose lol
- -----
- Printing debug shit to the console aside, having this kind of loop kinda causes the controller to be quite unresponsive outside of the plugin(which is not surprising, and was expected). :P
- Would it be a better option to completely hook the controller to the plugin, and then just redirect the button presses from the plugin to the PS3? I think I saw a method of doing that in some of Sony's documents/examples... Although Im not sure if it would work for a plugin, as pretty much all of sony's examples works from within a self(which seems to have more access, but sony doesnt know about CFW in their documents, so I dunno...).
- I dont want to copy mysis' method from his record plugin, as his button-registration to the plugin is slow-as-hell, thats not really what Im after. At the moment I pretty much just want to show the buttons "live", not X seconds after the press(mysis' R3(start recording) can take up to 10sec to register :/).
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 21, 2015
- sys_timer_usleep(100); is nothing
- If I have a menu and would select a line e.g. with d-pad up/down, I use a button delay of 80000 or 100000(1/10 sec)
- or it is not posible to select proper, too fast.
- And I use CEX, so I have no tty syscalls.
- How look your dbprint() ?
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- I posted it earlier, but here it is again(you even commented about it, about the return etc :>);
- int dbprint(const char * text, ...)
- {
- uint32_t len;
- system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- return 1;
- }
- Btw, 100ms is, last I checked, 1/10th of a second ;)
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 21, 2015
- u(micro)sleep(), not milli ;) 1/10 sec = 100 millisecond = 100000 microseconds
- int dbprint(const char * text, ...) the ... is useless, int dbprint(const char * text)
- I test some things...
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- Thats funny, because usleep(2000) results in the exact same delay as sleep(2)? :s
- And sony docs even said it was used for ms... I'll try increasing the delay just-because. I actually believe you more than Sony's pile of garbage docs lol, because I reacted to the func.naming and sonys docs when I first read it as well.
- On 2/21/2015 at 4:23 AM, 3141card said:
- int dbprint(const char * text, ...) the ... is useless, int dbprint(const char * text)
- I know the "..." is useless, I was trying a few things and just havnt removed it. :) It doesnt harm anyone being there, except looking ugly of course.
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 21, 2015
- I think this it you search for:
- #include <stdio.h>
- #include <stdarg.h> // for va_list, va_start, va_arg, va_end
- ...
- extern "C" void dbprint(const char * text, ...)
- {
- uint32_t len;
- char buf[0x200];
- va_list arg;
- va_start(arg, text);
- vsnprintf(buf, sizeof(buf), text, arg);
- va_end(arg);
- system_call_4(403, 0, (uint64_t) buf, strlen(buf), (uint64_t) &len); //tty write
- }
- ...
- dbprint("test: %d", 666); // output: test: 666
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- Thanks, unfortunately that gave me about the same result as my own attempts, namely some kind of crash on load(or, more accurately, the first call to dbprint()).
- Heres the log, maybe you can make some sense of it lol:
- Reveal hidden contents
- HAI! lv2(2): # lv2(2): # lv2(2): # system software version: 4.65 (DEX) lv2(2): # revision: 50402 lv2(2): # lv2(2): # Lv-2 detected an interrupt(exception) in a user PPU Thread. lv2(2): # lv2(2): # Interrupt(exception) Info. lv2(2): # Type : Data Segment lv2(2): # SRR0 : 0x00000000000a4e68 lv2(2): # SRR1 : 0x800000000000c032 lv2(2): # DSISR: 0x0000000000200000 lv2(2): # DAR : 0xffffffffffff90a8 lv2(2): # TB : 0x0000000250a1db50 lv2(2): # HW Thread #: 1 lv2(2): # lv2(2): # Backtrace lv2(2): # 0xfffffffffffffffc lv2(2): # 0x00000000000aa544 lv2(2): # 0x00000000000a2c88 lv2(2): # 0x00000000008e0368 lv2(2): # 0x00000000008e0448 lv2(2): # 0xbadadd0010200fac lv2(2): # lv2(2): # User PPU Thread Info. lv2(2): # ID : 0x010200fb lv2(2): # Name : lv2(2): # Stack addr: 0x00000000d00c2000 lv2(2): # Stack size: 0x0000000000001000 lv2(2): # Priority : 0 lv2(2): # Proc name : /dev_flash/vsh/module/vsh.self lv2(2): # Proc ID : 0x1000300 lv2(2): # lv2(2): # Register Info. lv2(2): # LR: 0x00000000000aa548 CR:0x48000008 lv2(2): # CTR: 0x0000000000000000 lv2(2): # lv2(2): # GPR 0: 0x00000000000aa548 GPR 1: 0x00000000d00c2a20 lv2(2): # GPR 2: 0x0000000000705ea0 GPR 3: 0x00000000d00c2b20 lv2(2): # GPR 4: 0x00000000008e080c GPR 5: 0x000000007fffffff lv2(2): # GPR 6: 0x00000000d00c2b28 GPR 7: 0xffffffffffff90a8 lv2(2): # GPR 8: 0x0000000000000000 GPR 9: 0x00000000000001ff lv2(2): # GPR10: 0x8000000000402800 GPR11: 0x0000000000000000 lv2(2): # GPR12: 0x00000000006fca50 GPR13: 0x0000000000000000 lv2(2): # GPR14: 0x0000000000000000 GPR15: 0x0000000000000000 lv2(2): # GPR16: 0x0000000000000000 GPR17: 0x0000000000000000 lv2(2): # GPR18: 0x0000000000000000 GPR19: 0x0000000000000000 lv2(2): # GPR20: 0x0000000000000000 GPR21: 0x0000000000000000 lv2(2): # GPR22: 0x0000000000000000 GPR23: 0x0000000000000000 lv2(2): # GPR24: 0x0000000000000000 GPR25: 0x00000000d00c2b24 lv2(2): # GPR26: 0x00000000d00c2b28 GPR27: 0x00000000d00c2c80 lv2(2): # GPR28: 0x00000000008e080c GPR29: 0x00000000008e080c lv2(2): # GPR30: 0x00000000d00c2b20 GPR31: 0x00000000008e080c lv2(2): # lv2(2): # XER: 0x0000000000000000 FPSCR: 0x00000000 lv2(2): # lv2(2): # FPR 0: 0x00000010203fb000 FPR 1: 0x0000000000000000 lv2(2): # FPR 2: 0x0000000000000000 FPR 3: 0x0000000000000000 lv2(2): # FPR 4: 0x0000000000000000 FPR 5: 0x0000000000000000 lv2(2): # FPR 6: 0x0000000000000000 FPR 7: 0x0000000000000000 lv2(2): # FPR 8: 0x0000000000000000 FPR 9: 0x0000000000000000 lv2(2): # FPR10: 0x0000000000000000 FPR11: 0x0000000000000000 lv2(2): # FPR12: 0x0000000000000000 FPR13: 0x0000000000000000 lv2(2): # FPR14: 0x0000000000000000 FPR15: 0x0000000000000000 lv2(2): # FPR16: 0x0000000000000000 FPR17: 0x0000000000000000 lv2(2): # FPR18: 0x0000000000000000 FPR19: 0x0000000000000000 lv2(2): # FPR20: 0x0000000000000000 FPR21: 0x0000000000000000 lv2(2): # FPR22: 0x0000000000000000 FPR23: 0x0000000000000000 lv2(2): # FPR24: 0x0000000000000000 FPR25: 0x0000000000000000 lv2(2): # FPR26: 0x0000000000000000 FPR27: 0x0000000000000000 lv2(2): # FPR28: 0x0000000000000000 FPR29: 0x0000000000000000 lv2(2): # FPR30: 0x0000000000000000 FPR31: 0x0000000000000000 lv2(2): # lv2(2): # PRX Info: 5 PRX in process lv2(2): # --/--: id-------- path------------------------------ version segments--- lv2(2): # 0/ 5: 0x23001603 [/dev_flash/sys/internal/sys_audio.sprx] 1. 1 2 segme nts lv2(2): # ---/--- base------+filesz----+(mem-file) [flags-----] lv2(2): # 0/ 2: 0x00770000+0x000aa080+0x00000000 [0x00000001] lv2(2): # 1/ 2: 0x00820000+0x00004574+0x00039d74 [0x00000001] lv2(2): # 1/ 5: 0x23003606 [/dev_flash/vsh/module/webftp_server.sprx] 0. 1 2 seg ments lv2(2): # ---/--- base------+filesz----+(mem-file) [flags-----] lv2(2): # 0/ 2: 0x00cc0000+0x0002980c+0x00000000 [0x00000001] lv2(2): # 1/ 2: 0x00b60000+0x00004e44+0x00000928 [0x00000001] lv2(2): # 2/ 5: 0x23010e06 [/dev_flash/vsh/module/basic_plugins.sprx] 1. 1 2 seg ments lv2(2): # ---/--- base------+filesz----+(mem-file) [flags-----] lv2(2): # 0/ 2: 0x00860000+0x0004e6f0+0x00000000 [0x00000001] lv2(2): # 1/ 2: 0x008b0000+0x00002714+0x00003a88 [0x00000001] lv2(2): # 3/ 5: 0x23010408 [/dev_flash/vsh/module/eseidle.sprx] 1. 1 2 segments lv2(2): # ---/--- base------+filesz----+(mem-file) [flags-----] lv2(2): # 0/ 2: 0x008c0000+0x00000d5c+0x00000000 [0x00000001] lv2(2): # 1/ 2: 0x008d0000+0x000000d4+0x00005144 [0x00000001] lv2(2): # 4/ 5: 0x23023807 [/dev_hdd0/game/PRXLOADER/USRDIR/simple-c_prx.sprx] 1. 1 2 segments lv2(2): # ---/--- base------+filesz----+(mem-file) [flags-----] lv2(2): # 0/ 2: 0x008e0000+0x00000850+0x00000000 [0x00000001] lv2(2): # 1/ 2: 0x008f0000+0x00000070+0x00000018 [0x00000001] lv2(2): # lv2(2): # Continue... (Lv-2 is still running.) lv2(2): # lv2(2): System Warning : busy loop detected lv2(2): System Warning : busy loop detected lv2(2): System Warning : busy loop detected lv2(2): System Warning : busy loop detected <-- continues until I reset the , black screen
- And this is how it should look when everything's fine:
- Game: game exec processID = [0x01010200]
- HAI!
- Thread created
- Im ready!
- Note that these are still just string calls(dbprint("HAI! \n") for example). I tried changing the first call to "dbprint("HAI! %d\n", 123)", and the same thing happened, except "HAI! 123" got printed after the error log, before the system warning.
- Seeing as it did in fact print the "123" part, the function code itself seems to be working, but something is causing the ps3 to freeze after the first call. :(
- Edit: And yes, this IS exactly what Im looking for and been trying to pull off for quite a while now lol
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 21, 2015
- No idea, I never use tty.
- Maybe you can try a other channel than 0, 0 to 2 are system reserved, 3 to 15 are for user.
- Maybe this fix the prob.
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- Unfortunately, changing channel did jack-squat, still same shit... ughhhhhhhhhhhh *flips table*
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- vsnprintf(buf, sizeof(buf), text, arg);
- Thats what causing the freeze/crash, if I comment that line it doesnt freeze. If I comment any other line except that one, the freeze still happens
- edit: after sniffing google Ive concluded the crash happens when trying to convert int to char *. When doing the conversion, 1 of 2 things happens: First one is a crash/freeze, second one is nothing. Nothing at all.
- I think I've gone through all different methods by now, except 'itoa', as that command doesnt exist(?). It exists in stdlib, but that doesnt help me lol...
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 21, 2015
- Sry my friend, I forget something into the C++ plugin. And btw, it can't be vsnprintf().
- There is a usleep(70000) at the end of the main while of the cobra test plugin,
- the reason for this delay is the usage of cellPadGetData(0, &data).
- If our plugin ask, without delay, for pad data for pad port 0, than the vsh process
- can't ask, therefor pad bug into xmb. Our main while block the system:
- lv2(2): System Warning : busy loop detected (our main while)
- I use for a long time no own pad data struct or cellPadGetData() into my C plugins.
- I found it idiotic, to ask for data which are already here. The vsh process have a own
- pad data struct, so why ask a second time for data which are already exist.
- Therefore I forget it, add this delay at the end of your main while for proper sync:
- ...
- while(true)
- {
- if(cellPadGetData(0, &data) == CELL_PAD_OK && data.len > 0)
- {
- bool start = (data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START);
- if(start)
- {
- exit_thread = true;
- vshtask_notify("plugin stop...");
- }
- }
- if(exit_thread == true)
- ppu_thread_exit();
- sys_timer_usleep(70000); // pad get data sync delay
- } // main while end
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- FIXED IT! all by myself lol(see, I can do something on my own!). So this is how I had to do it:
- //inside while(true), after checking pad data etc
- char f[0x40];
- snprintf(f,100,"moo %02d ", data.button[CELL_PAD_BTN_OFFSET_PRESS_R2]);
- dbprint(f);
- sys_timer_usleep(100000);
- f[sizeof(f) / sizeof(f[0])] = '\0';
- //rinse and repeat
- Output:
- Im ready!
- moo 255 moo 255 moo 255 moo 255 moo 255 moo 255 moo 255 moo 255 moo 100 moo 127 moo 66 mo
- o 72 moo 56 moo 56 moo 18 moo 39 moo 38 moo 58 moo 255 moo 255 moo 50 moo 55 moo 97 moo 2
- 55 moo 255 moo 122 moo 108 moo 190 moo 255 moo 255
- Im going to tidy it up so it looks better... atm its a mess lol.
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 21, 2015
- sys_timer_usleep(100000); this is the fix, a delay for non blocking the vsh
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- Ive had that all a long though, well, since you said that thing about usleep a couple of posts back.
- ----
- Dunno if its something still not right with my code, or if its just something else, but it seems to randomly lose the pressed-data, resulting in it becoming unresponsive for a little while, then it picks up again just fine. Meh, dont care, I got my debug-printing-function now and it works fine, and the controller no longer clogs up in XMB like it used to(So I guess you were right about usleep :)).
- With that out of the way, I can actually start trying to MAKE something out of this lol
- Upvote 1
- 3141card reacted to this
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 21, 2015
- Ok, than learn, try out things and release nice stuff in future :)
- Upvote 1
- Lucif3r reacted to this
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- Well, merging the above into the dbprint function caused it to go haywire again(freezing).. After much trial and error I have found the cause, but no solution...
- The cause is when you call dbprint with no extra argument, e.g 'dbprint("string!");'. That will cause the freeze Ive struggled with for so long. However, calling dbprint with another arg, e.g 'dbprint("string! %d", 1);' works just fine.
- And there doesnt seem to be any way of determining if va_list contains an additional argument or not, at least not if the static arg isnt an int(and in my case its a char*) :(
- So, yeah, unless someone has a cleaver way of determining if theres an addition argument or not, I guess I'll just have to split it into 2 different functions.
- Heres the dbprint in its current form for reference, its not much different from 3141card's on the previous page(which has the exact same issue).
- void dbprint(const char * text, ...)
- {
- uint32_t len;
- va_list arg;
- char f[0x40];
- va_start(arg, text);
- int g = va_arg(arg, int);
- sprintf(f,text, g);
- va_end(arg);
- system_call_4(403, 3, (uint64_t) f, strlen(f), (uint64_t) &len); //tty write
- f[sizeof(f) / sizeof(f[0])] = '\0';
- }
- So, yeah, it works fine when theres an additional arg, but not as a single-arg call. According to all info I found on google, passing no argument shouldnt be an issue... But the PS3 obviously thinks otherwise....
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 21, 2015
- First experiment = success! Its not much, just remapped the controller to do other stuff when buttons are pressed...
- Still, its a start!
- 9q1Qe7i.png
- Upvote 2
- sandungas and TheDarkprogramer reacted to this
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 22, 2015
- I switch to DEX to for test it, the code I post works fine.
- prx: no var's
- prx: 666
- prx: 888 0x1234AABB
- prx: 0.967000
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: r2 pressed
- prx: start pressed
- no probs with dbprintf():
- extern "C" void dbprint(const char * text, ...)
- {
- uint32_t len;
- char buf[0x200];
- va_list arg;
- va_start(arg, text);
- vsnprintf(buf, sizeof(buf), text, arg);
- va_end(arg);
- //vshtask_notify(buf);
- system_call_4(403, 0, (uint64_t) buf, strlen(buf), (uint64_t) &len); //tty write
- }
- ...
- // into main thread
- dbprint("prx: no var's\n");
- dbprint("prx: %d\n", 666);
- dbprint("prx: %d 0x%08X\n", 888, 0x1234AABB);
- dbprint("prx: %f\n", 0.967);
- ...
- // into main while
- if(start)
- {
- exit_thread = true;
- dbprint("prx: start pressed\n");
- sys_timer_usleep(300000);
- }
- if(r2)
- {
- dbprint("prx: r2 pressed\n");
- sys_timer_usleep(300000);
- }
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 22, 2015
- Funny... Any theories why it goes completely emo for me?
- I split it into 2 funcs. yesterday and that works just fine, calling them at the same time, spamming them etc etc. But as soon as I try to call dbprint(char*, ...) without an additional arg it gives me the finger lol...
- Could it be FW or SDK related? Im using sony's 3.70 SDK, on VSC2010, along with rebug 4.65.2(previously tried on rebug 4.46, same thing there).
- This is how I do it now anyway.
- void dbprintf(const char * text, ...)
- //'extern "C" ' or not doesnt make a difference, and your function causes the exact same issues.
- //I chose to keep my function over yours though because... Well, I made it :P, cant keep copy-pasting everyone else's code if I want to learn^^
- {
- uint32_t len;
- va_list arg;
- char f[0x40];
- va_start(arg, text);
- int g = va_arg(arg, int);
- sprintf(f,text, g);
- va_end(arg);
- system_call_4(403, 3, (uint64_t) f, strlen(f), (uint64_t) &len); //tty write
- f[sizeof(f) / sizeof(f[0])] = '\0';
- }
- void dbprint(const char * text, ...)
- {
- uint32_t len;
- system_call_4(403, 3, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
- }
- //main
- while(true)
- {
- if(cellPadGetData(0, &data) == CELL_PAD_OK && data.len > 0)
- {
- if(data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] > 0)
- {
- dbprintf("R2; %d pressure ", data.button[CELL_PAD_BTN_OFFSET_PRESS_R2]);
- data.button[3] = CELL_PAD_CTRL_CIRCLE;
- cellPadLddDataInsert( vPadHandle, &data );
- dbprint("Circle was pressed!\n");
- sys_timer_sleep(1); //going to adjust this sleep obviously, theres no point to have a whole second delay here.
- //my awesome R2 "remapper", aint it a beauty? lol........ its shit I know :(
- }
- }
- }
- Oh, and again, thank you for all your help. If it wasnt for your help, I'd given up ages ago :P
- Upvote 1
- 3141card reacted to this
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 22, 2015 (edited)
- No idea :(
- Iam furthermore on 4.46 rebug, make norbin dump with toolbox, convert with cec2dex, flash it with mm, change lv2 kernel in toolbox.
- sdk 400.001, TM 400.1.35.3, VS2010(I add also sys_prx_for_user_export_stub_lib, but the sample prx use no export from this module)
- and vsnprintf() is from stdc_lib not sys_vsnprintf() aka sysPrxForUser_0618936B.
- And no prob, its a nice hobby :)
- EDIT: I think not is a versions prob, new sdks have often impro. of highlevel stuff like thread managment
- and such things, but simply lowlevel things like tty...
- Edited February 22, 2015 by 3141card
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 22, 2015
- I dont suppose you know how to intercept a button command? e.g. preventing it from doing stuff on the PS3? Simply setting the button to 'not pressed'-state right when its pressed doesnt work :)
- I can make the buttons do other stuff just fine, but not stopping it from doing its original task(e.g. 'accept' or similar) at the same time :)
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 22, 2015
- I use only delays to prevent to fast inputs, works fine for me, even in complex psl1ght progs
- with menus.
- What you search for need status variables, something like old_pad, new_pad...
- sure you will find something in the sdk samples, e.g. sysutil/, I never need it.
- 0
- Lucif3r
- Sarcasmaclysmic
- Lucif3r
- Super Admin
- Founding Member
- 2,459
- 2,945 posts
- Location: Far away, in a dark cave ,,^..^,,
- Posted February 22, 2015
- Okey, yeah I got all the pad examples open, but as usual they are meant for .self's. I also noticed I have no control over the pad in a game, dunno if its possible to get around that, or if youre limited to XMB(or your own self's)...
- therifboy
- Newbie
- therifboy
- New Member
- 0
- 4 posts
- Posted February 22, 2015 (edited)
- You don't really need to have your own version of printf seeing VSH is exporting it. Link your program to -lc_stub. (unlink -lc)
- You'll have a new import stub in your plugin.
- http://i.imgur.com/NfKAMAV.png
- VSH exports that same stub but under a different name.
- http://i.imgur.com/lLrEpa7.png
- What I do is open up my plugin, edit "sys_libc" to "stdc". The ps3 will take care of the rest. I don't know if there's an easier way to match the strings.
- edit:
- f[sizeof(f) / sizeof(f[0])] = '\0';
- should be
- f[sizeof(f) / sizeof(f[0]) - 1] = '\0'; Edited February 22, 2015 by therifboy
- 0
- 3141card
- Member
- 3141card
- Founding Member
- V.I.P
- 172
- 112 posts
- Location: Germany
- Posted February 22, 2015
- I mean samples like recording, this samples needs a pad, look at this code. :)
- Pad events are only in xmb or ingame-xmb, not ingame, thats normal, I use a other way:
- CellPadData *getPadDataStruct()
- {
- uint64_t ret = 0;
- uint32_t start = 0x00708B10; // start .bss segment
- int32_t size = 0x00049010; // size .bss segment
- while(start != (start + size)){
- if((ret = *(uint64_t*)start) == 0x0000004600000046ULL)
- return (CellPadData*)(start - 0x8C);
- start+=8;
- }
- return (CellPadData*)0;
- }
- ...
- //CellPadData data;
- CellPadData *data = getPadDataStruct();
- while(true)
- {
- // ask for data of the vsh pad data struct, no need for a own
- if(data->len > 0)
- {
- if(data->button[2] & CELL_PAD_CTRL_START)
- {
- exit_thread = true;
- dbprint("prx: start pressed\n");
- sys_timer_usleep(300000);
- }
- if(data->button[3] & CELL_PAD_CTRL_R2)
- {
- dbprint("prx: r2 pressed\n");
- sys_timer_usleep(300000);
- }
- }
- if(exit_thread == true)
- ppu_thread_exit();
- sys_timer_usleep(70000);
- }
- the vsh_pad_data are available all the time, not only in xmb and ingame xmb,
- but there is no warranty that it is generic. The search value is from a other pad object, maybe not ever
- direct behind vsh_pad_data or a other value.
- Hi therifboy :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement