Advertisement
Guest User

Help getting started with making plugins :d

a guest
Apr 21st, 2019
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.46 KB | None | 0 0
  1. Help getting started with making plugins :d
  2. https://playstationhax.xyz/forums/topic/1382-help-getting-started-with-making-plugins-d/
  3.  
  4.  
  5. Help getting started with making plugins :d
  6. Asked by Lucif3r
  7. noob
  8.  
  9. ambitious
  10.  
  11. rubbish
  12.  
  13. gtfo
  14. Question
  15. Lucif3r
  16. Sarcasmaclysmic
  17. Lucif3r
  18. Super Admin
  19.  
  20. Founding Member
  21. 2,459
  22. 2,945 posts
  23. Location: Far away, in a dark cave ,,^..^,,
  24. Posted February 17, 2015
  25. So, I fell and hit my head and thought it would be a BRILLIANT idea to learn a bit about plugins, prx ones specifically.
  26.  
  27. After a few days frustration and reading I finally got my environment set up and got it to build shit. Yay.
  28.  
  29.  
  30.  
  31. 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.
  32.  
  33. 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. :/
  34.  
  35. I am obviously missing something here, probably simple as hell...
  36.  
  37.  
  38.  
  39. So, heres the code that freezes during load:
  40.  
  41. #include <sys/prx.h>
  42.  
  43. SYS_MODULE_INFO( shityPRX, 0, 1, 0 );
  44. SYS_MODULE_START( _start );
  45. SYS_MODULE_STOP( _stop );
  46.  
  47. int _start(void);
  48. int _stop(void);
  49.  
  50. int _start(void)
  51. {
  52. return SYS_PRX_RESIDENT;
  53. }
  54.  
  55. int _stop(void)
  56. {
  57. return SYS_PRX_STOP_OK;
  58. }
  59. And by blatantly stealing Mysis' ppu_thread_create function from his recording plugin, and adding the following;
  60.  
  61. void thread_entry(uint64_t arg)
  62. {
  63. sys_timer_sleep(10);
  64. }
  65. the plugin loads fine, but freezes shortly after returning to xmb(I assume just about when sleep(x) runs out).
  66.  
  67. 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.
  68.  
  69. 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 :(
  70.  
  71.  
  72.  
  73. 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...
  74.  
  75. Unfortunately C#/windows does a lot automatically, such as handling the 'idling' of a program, which doesnt really help me fixing this issue...
  76.  
  77.  
  78.  
  79. 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?
  80.  
  81.  
  82.  
  83.  
  84.  
  85. 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... :(
  86.  
  87. Upvote 2
  88. TheDarkprogramer and 3141card reacted to this
  89.  
  90. SORT BY VOTES
  91. SORT BY DATE
  92. 1 2 3 NEXT Page 1 of 3
  93. 0
  94. 3141card
  95. Member
  96. 3141card
  97. Founding Member
  98.  
  99. V.I.P
  100. 172
  101. 112 posts
  102. Location: Germany
  103. Posted February 17, 2015 (edited)
  104. #include <sys/prx.h>
  105. #include <sys/ppu_thread.h>
  106. #include <sys/syscall.h> // for syscall usage
  107.  
  108.  
  109. #include <stdio.h>
  110. #include <stdlib.h>
  111. #include <string.h>
  112.  
  113.  
  114.  
  115. SYS_MODULE_INFO(TESTPLUGIN, 0, 1, 0); // plugin info
  116. SYS_MODULE_START(testplugin_start); // plugin start function
  117. SYS_MODULE_STOP(testplugin_stop); // plugin stop function
  118.  
  119. // thread names, optional and here over macros, names are usefull for debug
  120. #define THREAD_NAME "testplugin_thread"
  121. #define STOP_THREAD_NAME "testplugin_stop_thread"
  122.  
  123. // global variables
  124. static sys_ppu_thread_t thread_id = -1;
  125.  
  126. // functions prototypes
  127. int testplugin_start(uint64_t arg);
  128. int testplugin_stop(void);
  129.  
  130.  
  131. // exit over syscall or crash
  132. static inline void _sys_ppu_thread_exit(uint64_t val)
  133. {
  134. system_call_1(41, val);
  135. }
  136.  
  137. static inline sys_prx_id_t prx_get_module_id_by_address(void *addr)
  138. {
  139. system_call_1(461, (uint64_t)(uint32_t)addr);
  140. return (int)p1;
  141. }
  142.  
  143.  
  144. // plugin main ppu thread, like main in normal c prog
  145. static void testplugin_thread(uint64_t arg)
  146. {
  147.  
  148. // do work...
  149.  
  150. sys_ppu_thread_exit(0); // here ends the plugin. like return(0); on main end in c
  151. }
  152.  
  153. // plugin start function, start our main ppu thread...
  154. int testplugin_start(uint64_t arg)
  155. {
  156. sys_ppu_thread_create(&thread_id, testplugin_thread, 0, 3000, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, THREAD_NAME);
  157.  
  158. // Exit thread using directly the syscall and not the user mode library or we will crash
  159. _sys_ppu_thread_exit(0);
  160. return SYS_PRX_RESIDENT;
  161. }
  162.  
  163. // plugin exit function, proper stop our plugin
  164. static void testplugin_stop_thread(uint64_t arg)
  165. {
  166. done = 1;
  167.  
  168. if (thread_id != (sys_ppu_thread_t)-1)
  169. {
  170. uint64_t exit_code;
  171. sys_ppu_thread_join(thread_id, &exit_code);
  172. }
  173.  
  174. sys_ppu_thread_exit(0);
  175. }
  176.  
  177. static void finalize_module(void)
  178. {
  179. uint64_t meminfo[5];
  180.  
  181. sys_prx_id_t prx = prx_get_module_id_by_address(finalize_module);
  182.  
  183. meminfo[0] = 0x28;
  184. meminfo[1] = 2;
  185. meminfo[3] = 0;
  186.  
  187. system_call_3(482, prx, 0, (uint64_t)(uint32_t)meminfo);
  188. }
  189.  
  190. int testplugin_stop(void)
  191. {
  192. sys_ppu_thread_t t;
  193. uint64_t exit_code;
  194.  
  195. sys_ppu_thread_create(&t, testplugin_stop_thread, 0, 0, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, STOP_THREAD_NAME);
  196. sys_ppu_thread_join(t, &exit_code);
  197.  
  198. finalize_module();
  199. _sys_ppu_thread_exit(0);
  200. return SYS_PRX_STOP_OK;
  201. }
  202. Based on the cobra test plugin.
  203.  
  204.  
  205.  
  206. EDIT: this is for C, (I like smal plugins).
  207.  
  208.  
  209.  
  210. Use User's test plugin(into PRXLoader download) for VS and C++.
  211.  
  212. #include <cellstatus.h>
  213. #include <sys/prx.h>
  214. #include <stdio.h>
  215. #include <stdlib.h>
  216. #include <string.h>
  217.  
  218. SYS_MODULE_INFO( test_prx, 0, 1, 1);
  219. SYS_MODULE_START( _test_prx_prx_entry );
  220.  
  221. SYS_LIB_DECLARE( cellPrx_test_prx, SYS_LIB_AUTO_EXPORT );
  222. SYS_LIB_EXPORT( _test_prx_export_function, cellPrx_test_prx );
  223.  
  224. void ppu_thread_exit()
  225. {
  226. system_call_1(41, 0); //ppu_thread_exit
  227. }
  228.  
  229.  
  230. // An exported function is needed to generate the project's PRX stub export library
  231. extern "C" int _test_prx_export_function(void)
  232. {
  233. return CELL_OK;
  234. }
  235.  
  236. extern "C" int _test_prx_prx_entry(void)
  237. {
  238. char test[] = "Hello VSH\n";
  239. uint32_t len;
  240. system_call_4(403, 0, (uint64_t) test, strlen(test), (uint64_t) &len); //tty write
  241. ppu_thread_exit();
  242. return SYS_PRX_RESIDENT;
  243. }
  244. Edited February 18, 2015 by 3141card
  245. Upvote 2
  246. TheDarkprogramer and mysis reacted to this
  247. 0
  248. TheDarkprogramer
  249. PlayStationHaX Guru
  250. TheDarkprogramer
  251. Developer
  252.  
  253. Founding Member
  254. V.I.P
  255. 848
  256. 1,215 posts
  257. Location: Somewhere In South Africa
  258. Posted February 18, 2015
  259. Nice read means I can learn alot too as im also stuggeling switching to object c /c++
  260.  
  261. 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
  262.  
  263. 0
  264. 3141card
  265. Member
  266. 3141card
  267. Founding Member
  268.  
  269. V.I.P
  270. 172
  271. 112 posts
  272. Location: Germany
  273. Posted February 18, 2015 (edited)
  274. I use mostly cygwin under win7, here I have my old psl1ght. The "other SDK" cell dir is copyed to
  275.  
  276. cygwin/usr/local.
  277.  
  278.  
  279. psl1ght and "other SDK" together without trouble.
  280.  
  281.  
  282.  
  283. I code only in C and compile in cygwin console, my editor for writing source code is Geany.
  284.  
  285.  
  286.  
  287. I have VS2010 too(some samples need VS, not many), but don't like it.
  288.  
  289. Edited February 18, 2015 by 3141card
  290. 0
  291. Lucif3r
  292. Sarcasmaclysmic
  293. Lucif3r
  294. Super Admin
  295.  
  296. Founding Member
  297. 2,459
  298. 2,945 posts
  299. Location: Far away, in a dark cave ,,^..^,,
  300. Posted February 18, 2015
  301. On 2/17/2015 at 11:37 PM, 3141card said:
  302. Based on the cobra test plugin.
  303.  
  304.  
  305.  
  306. EDIT: this is for C, (I like smal plugins).
  307.  
  308.  
  309.  
  310. Use User's test plugin(into PRXLoader download) for VS and C++.
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318. Are those 2 examples supposed to compile properly on their own? Because...
  319.  
  320.  
  321.  
  322. First example:
  323.  
  324. 1>------ Rebuild All started: Project: mooo, Configuration: Debug PS3 ------
  325. 1> cobra.cpp
  326. 1>cobra.cpp(21,36): warning 68: integer conversion resulted in a change of sign
  327. 1>
  328. 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 *"
  329. 1>
  330. 1>cobra.cpp(22,11): warning 552: variable "done" was set but never used <--- what? It is used!
  331. 1>
  332. 1> ppu-lv2-prx-libgen.exe: "module_start(=testplugin_start)" is undefine symbol. can't export.
  333. 1> ps3ppuld 370.1.4467.0 (rel,TR,1.3_995_370,src @112234 #451087 ) "F:\SCE\370\host-win32\sn\bin\ps3ppuld.exe"
  334. 1>Command line : error : L0303: error generating PRX (prx-libgen failed)
  335. 1>Command line : error : L0064: Linking aborted
  336. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  337. second:
  338.  
  339. 1>------ Rebuild All started: Project: mooo, Configuration: Debug PS3 ------
  340. 1> cobra.cpp
  341. 1> undefined reference to `memcpy'
  342. 1> undefined reference to `strlen'
  343. 1> ps3ppuld 370.1.4467.0 (rel,TR,1.3_995_370,src @112234 #451087 ) "F:\SCE\370\host-win32\sn\bin\ps3ppuld.exe"
  344. 1>Command line : error : L0303: error generating PRX (prx-fixup failed)
  345. 1>Command line : error : L0064: Linking aborted
  346. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  347. :(
  348.  
  349.  
  350.  
  351. Im using VSC2010 with the sony 3.70(because the 4.0 refuses to work) SDK and VS plugin.
  352.  
  353. 0
  354. 3141card
  355. Member
  356. 3141card
  357. Founding Member
  358.  
  359. V.I.P
  360. 172
  361. 112 posts
  362. Location: Germany
  363. Posted February 18, 2015
  364. 1. is not for VS, you need a makefile...
  365.  
  366.  
  367.  
  368. 2. you need the full project, look for the test_prx folder in PRXLoader download.
  369.  
  370. open the test_prx.sln with VS. Here are e.g. libc.c missing for `memcpy' and `strlen'.
  371.  
  372.  
  373.  
  374.  
  375.  
  376. Upvote 1
  377. Lucif3r reacted to this
  378. 0
  379. Frankie
  380. Member
  381. Frankie
  382. Regular Member
  383.  
  384. 2
  385. 14 posts
  386. Posted February 18, 2015
  387. On 2/17/2015 at 11:37 PM, 3141card said:
  388. #include <sys/prx.h>
  389. #include <sys/ppu_thread.h>
  390. #include <sys/syscall.h> // for syscall usage
  391.  
  392.  
  393. #include <stdio.h>
  394. #include <stdlib.h>
  395. #include <string.h>
  396.  
  397.  
  398.  
  399. SYS_MODULE_INFO(TESTPLUGIN, 0, 1, 0); // plugin info
  400. SYS_MODULE_START(testplugin_start); // plugin start function
  401. SYS_MODULE_STOP(testplugin_stop); // plugin stop function
  402.  
  403. // thread names, optional and here over macros, names are usefull for debug
  404. #define THREAD_NAME "testplugin_thread"
  405. #define STOP_THREAD_NAME "testplugin_stop_thread"
  406.  
  407. // global variables
  408. static sys_ppu_thread_t thread_id = -1;
  409.  
  410. // functions prototypes
  411. int testplugin_start(uint64_t arg);
  412. int testplugin_stop(void);
  413.  
  414.  
  415. // exit over syscall or crash
  416. static inline void _sys_ppu_thread_exit(uint64_t val)
  417. {
  418. system_call_1(41, val);
  419. }
  420.  
  421. static inline sys_prx_id_t prx_get_module_id_by_address(void *addr)
  422. {
  423. system_call_1(461, (uint64_t)(uint32_t)addr);
  424. return (int)p1;
  425. }
  426.  
  427.  
  428. // plugin main ppu thread, like main in normal c prog
  429. static void testplugin_thread(uint64_t arg)
  430. {
  431.  
  432. // do work...
  433.  
  434. sys_ppu_thread_exit(0); // here ends the plugin. like return(0); on main end in c
  435. }
  436.  
  437. // plugin start function, start our main ppu thread...
  438. int testplugin_start(uint64_t arg)
  439. {
  440. sys_ppu_thread_create(&thread_id, testplugin_thread, 0, 3000, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, THREAD_NAME);
  441.  
  442. // Exit thread using directly the syscall and not the user mode library or we will crash
  443. _sys_ppu_thread_exit(0);
  444. return SYS_PRX_RESIDENT;
  445. }
  446.  
  447. // plugin exit function, proper stop our plugin
  448. static void testplugin_stop_thread(uint64_t arg)
  449. {
  450. done = 1;
  451.  
  452. if (thread_id != (sys_ppu_thread_t)-1)
  453. {
  454. uint64_t exit_code;
  455. sys_ppu_thread_join(thread_id, &exit_code);
  456. }
  457.  
  458. sys_ppu_thread_exit(0);
  459. }
  460.  
  461. static void finalize_module(void)
  462. {
  463. uint64_t meminfo[5];
  464.  
  465. sys_prx_id_t prx = prx_get_module_id_by_address(finalize_module);
  466.  
  467. meminfo[0] = 0x28;
  468. meminfo[1] = 2;
  469. meminfo[3] = 0;
  470.  
  471. system_call_3(482, prx, 0, (uint64_t)(uint32_t)meminfo);
  472. }
  473.  
  474. int testplugin_stop(void)
  475. {
  476. sys_ppu_thread_t t;
  477. uint64_t exit_code;
  478.  
  479. sys_ppu_thread_create(&t, testplugin_stop_thread, 0, 0, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, STOP_THREAD_NAME);
  480. sys_ppu_thread_join(t, &exit_code);
  481.  
  482. finalize_module();
  483. _sys_ppu_thread_exit(0);
  484. return SYS_PRX_STOP_OK;
  485. }
  486. Based on the cobra test plugin.
  487.  
  488.  
  489.  
  490. EDIT: this is for C, (I like smal plugins).
  491.  
  492.  
  493.  
  494. Use User's test plugin(into PRXLoader download) for VS and C++.
  495.  
  496. #include <cellstatus.h>
  497. #include <sys/prx.h>
  498. #include <stdio.h>
  499. #include <stdlib.h>
  500. #include <string.h>
  501.  
  502. SYS_MODULE_INFO( test_prx, 0, 1, 1);
  503. SYS_MODULE_START( _test_prx_prx_entry );
  504.  
  505. SYS_LIB_DECLARE( cellPrx_test_prx, SYS_LIB_AUTO_EXPORT );
  506. SYS_LIB_EXPORT( _test_prx_export_function, cellPrx_test_prx );
  507.  
  508. void ppu_thread_exit()
  509. {
  510. system_call_1(41, 0); //ppu_thread_exit
  511. }
  512.  
  513.  
  514. // An exported function is needed to generate the project's PRX stub export library
  515. extern "C" int _test_prx_export_function(void)
  516. {
  517. return CELL_OK;
  518. }
  519.  
  520. extern "C" int _test_prx_prx_entry(void)
  521. {
  522. char test[] = "Hello VSH\n";
  523. uint32_t len;
  524. system_call_4(403, 0, (uint64_t) test, strlen(test), (uint64_t) &len); //tty write
  525. ppu_thread_exit();
  526. return SYS_PRX_RESIDENT;
  527. }
  528. Do you know the syscall or command for disabling the process in TM so no one can view memory to edit it?
  529.  
  530. 0
  531. 3141card
  532. Member
  533. 3141card
  534. Founding Member
  535.  
  536. V.I.P
  537. 172
  538. 112 posts
  539. Location: Germany
  540. Posted February 18, 2015
  541. 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.
  542.  
  543. 0
  544. Lucif3r
  545. Sarcasmaclysmic
  546. Lucif3r
  547. Super Admin
  548.  
  549. Founding Member
  550. 2,459
  551. 2,945 posts
  552. Location: Far away, in a dark cave ,,^..^,,
  553. Posted February 18, 2015
  554. On 2/18/2015 at 12:55 AM, 3141card said:
  555. 1. is not for VS, you need a makefile...
  556.  
  557.  
  558.  
  559. 2. you need the full project, look for the test_prx folder in PRXLoader download.
  560.  
  561. open the test_prx.sln with VS. Here are e.g. libc.c missing for `memcpy' and `strlen'.
  562.  
  563.  
  564.  
  565. 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...
  566.  
  567.  
  568.  
  569. Man, I have a lot to learn :P
  570.  
  571. 0
  572. 3141card
  573. Member
  574. 3141card
  575. Founding Member
  576.  
  577. V.I.P
  578. 172
  579. 112 posts
  580. Location: Germany
  581. Posted February 18, 2015 (edited)
  582. #include <cellstatus.h>
  583. #include <sys/prx.h>
  584. #include <stdio.h>
  585. #include <stdlib.h>
  586. #include <string.h>
  587.  
  588. SYS_MODULE_INFO( test_prx, 0, 1, 1);
  589. SYS_MODULE_START( _test_prx_prx_entry );
  590.  
  591. SYS_LIB_DECLARE( cellPrx_test_prx, SYS_LIB_AUTO_EXPORT );
  592. SYS_LIB_EXPORT( _test_prx_export_function, cellPrx_test_prx );
  593.  
  594. void ppu_thread_exit()
  595. {
  596. system_call_1(41, 0); //ppu_thread_exit
  597. }
  598.  
  599.  
  600. // An exported function is needed to generate the project's PRX stub export library
  601. extern "C" int _test_prx_export_function(void)
  602. {
  603. return CELL_OK;
  604. }
  605.  
  606. extern "C" int _test_prx_prx_entry(void)
  607. {
  608. // do work... e.g. your sleep
  609.  
  610. ppu_thread_exit();
  611. return SYS_PRX_RESIDENT;
  612. }
  613. This is, at bottom, the prototype you have to use for start your own projects.
  614.  
  615.  
  616.  
  617. EDIT:
  618.  
  619.  
  620.  
  621. Look also on mysis plugins, you can learn a lot from this :)
  622.  
  623. Edited February 18, 2015 by 3141card
  624. Upvote 1
  625. Lucif3r reacted to this
  626. 0
  627. Lucif3r
  628. Sarcasmaclysmic
  629. Lucif3r
  630. Super Admin
  631.  
  632. Founding Member
  633. 2,459
  634. 2,945 posts
  635. Location: Far away, in a dark cave ,,^..^,,
  636. Posted February 18, 2015
  637. I... see... So a lack of a simple ppu_thread_exit() was the cause of all this frustration... I knew it was simple -.-...
  638.  
  639. Plugin compiles and loads fine now, and I even added a function that worked!
  640.  
  641.  
  642.  
  643. Although I have (already lol) run into a new, weird, issue.
  644.  
  645.  
  646.  
  647. This is a sample to demonstrate the errors:
  648.  
  649. extern "C" int dbprint(char * text) //<- line 123
  650. {
  651. uint32_t len;
  652. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  653. return true; //<- line 128
  654. }
  655. -------------------------------------------------------
  656. 1>prx.c(123,7): error 40: expected an identifier
  657. 1>
  658. 1>prx.c(123,7): error 261-D: explicit type is missing ("int" assumed)
  659. 1>
  660. 1>prx.c(128,8): error 20: identifier "true" is undefined
  661. 1>
  662. 1>prx.c(207,1): warning 224: function "dbprint" declared implicitly <--- A call to the above function.
  663. Ok so, as you can see it doesnt accept "extern "C" ... ", and somehow it even complains that "true" is undefined.
  664.  
  665. 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.
  666.  
  667. 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...
  668.  
  669.  
  670.  
  671. My dbprint function works just fine btw, if I remove the extern "C" and "true"(which I added for demonstration).
  672.  
  673. 0
  674. 3141card
  675. Member
  676. 3141card
  677. Founding Member
  678.  
  679. V.I.P
  680. 172
  681. 112 posts
  682. Location: Germany
  683. Posted February 18, 2015
  684. extern "C" say the compiler that the code must be compiled with C compiler, in C there is no boolean per default,
  685.  
  686. to use bool in C I must include stdbool.h or define it self. -> http://stackoverflow.com/questions/1921539/using-boolean-values-in-c
  687.  
  688.  
  689.  
  690. 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,
  691.  
  692. than you can even use void dbprint().
  693.  
  694.  
  695.  
  696. btw, you are on the right way :) play with the code, source of other plugins and you learn it fast.
  697.  
  698. Upvote 1
  699. Lucif3r reacted to this
  700. 0
  701. Lucif3r
  702. Sarcasmaclysmic
  703. Lucif3r
  704. Super Admin
  705.  
  706. Founding Member
  707. 2,459
  708. 2,945 posts
  709. Location: Far away, in a dark cave ,,^..^,,
  710. Posted February 18, 2015
  711. Mmm, not sure you got what I meant, the errors are independant of each other.
  712.  
  713.  
  714.  
  715. I'll give you 2 more examples:
  716.  
  717. int dbprint(char * text)
  718. {
  719. uint32_t len;
  720. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  721. while(true)
  722. {
  723. //dostuff
  724. }
  725. }
  726. ------------------------------
  727. 1> libc.c
  728. 1> prx.c
  729. 1>prx.c(128,7): error 20: identifier "true" is undefined
  730. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  731. extern "C" int dbprint(char * text)
  732. {
  733. uint32_t len;
  734. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  735.  
  736. }
  737. ------------------------------------------
  738. 1> libc.c
  739. 1> prx.c
  740. 1>prx.c(123,7): error 40: expected an identifier
  741. 1>
  742. 1>prx.c(123,7): error 261-D: explicit type is missing ("int" assumed)
  743. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  744. int dbprint(char * text)
  745. {
  746. uint32_t len;
  747. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  748.  
  749. }
  750. -------------------------------------------
  751. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  752. And this is regardless of function, if both true/bool/etc and external "C" are present or not.
  753.  
  754.  
  755.  
  756. In fact, I'll throw in another example too. Just a normal definition, outside of any function:
  757.  
  758. bool exit_thread=false;
  759. sys_prx_id_t prx_id;
  760. sys_prx_module_info_t *pInfo;
  761. --------------------------------
  762. 1> libc.c
  763. 1> prx.c
  764. 1>prx.c(95): error 20: identifier "bool" is undefined
  765. 1>
  766. 1>prx.c(95,17): error 20: identifier "false" is undefined
  767. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  768. edit: Well, heres an example from test_prx that I just added a while(true) loop in:
  769.  
  770. extern "C" int _test_prx_prx_entry(void)
  771. {
  772. while(true)
  773. {
  774. //wasd
  775. }
  776. char test[] = "Hello VSH\n";
  777. uint32_t len;
  778. system_call_4(403, 0, (uint64_t) test, strlen(test), (uint64_t) &len); //tty write
  779. ppu_thread_exit();
  780. return SYS_PRX_RESIDENT;
  781. }
  782. -----------------------------
  783. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  784. And yeah, as I said, I have the same #include's in my code as test_prx have(incl. libc.c/libc.h)...
  785.  
  786.  
  787.  
  788. And heres the exact same thing in MY entry:
  789.  
  790. extern "C" int _prx_start(void)
  791. {
  792. while(true)
  793. {
  794. //fail
  795. }
  796. ppu_thread_exit();
  797. return SYS_PRX_RESIDENT;
  798. }
  799.  
  800. -------------------
  801. 1> libc.c
  802. 1> prx.c
  803. 1>prx.c(130,7): error 40: expected an identifier
  804. 1>
  805. 1>prx.c(130,7): error 261-D: explicit type is missing ("int" assumed)
  806. 1>
  807. 1>prx.c(132,7): error 20: identifier "true" is undefined
  808. 1>
  809. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  810. 0
  811. 3141card
  812. Member
  813. 3141card
  814. Founding Member
  815.  
  816. V.I.P
  817. 172
  818. 112 posts
  819. Location: Germany
  820. Posted February 18, 2015
  821. LOL, now I see, you have renamed prx.cpp to prx.c, a .c file is C code, the extern C is useless,
  822.  
  823. and bool is not available per default into C.
  824.  
  825.  
  826.  
  827. I think you would code in C++ like mysis ? Than you must use extern "C" for using C stuff.
  828.  
  829. to tell the compiler what into your C++ code is C code.
  830.  
  831. int dbprint(char * text) // a function into a C file, ok
  832. {
  833. uint32_t len;
  834. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  835. while(true) // true is bool, not per defaut in C -> error 20: undefined
  836. {
  837. //dostuff
  838. }
  839. // return an int; is also missing
  840. }
  841. ------------------------------
  842. 1> libc.c
  843. 1> prx.c
  844. 1>prx.c(128,7): error 20: identifier "true" is undefined
  845. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  846. extern "C" int dbprint(char * text) // no extern C, you are in C
  847. {
  848. uint32_t len;
  849. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  850. // return missing too
  851. }
  852. ------------------------------------------
  853. 1> libc.c
  854. 1> prx.c
  855. 1>prx.c(123,7): error 40: expected an identifier
  856. 1>
  857. 1>prx.c(123,7): error 261-D: explicit type is missing ("int" assumed)
  858. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  859. int dbprint(char * text)
  860. {
  861. uint32_t len;
  862. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  863. // return an int missing, no error in VS ?
  864. }
  865. -------------------------------------------
  866. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  867. Upvote 1
  868. Lucif3r reacted to this
  869. 0
  870. Lucif3r
  871. Sarcasmaclysmic
  872. Lucif3r
  873. Super Admin
  874.  
  875. Founding Member
  876. 2,459
  877. 2,945 posts
  878. Location: Far away, in a dark cave ,,^..^,,
  879. Posted February 18, 2015
  880. On 2/18/2015 at 5:37 AM, 3141card said:
  881.  
  882.  
  883. LOL, now I see, you have renamed prx.cpp to prx.c, a .c file is C code, the extern C is useless,
  884.  
  885. and bool is not available per default into C.
  886.  
  887.  
  888.  
  889.  
  890.  
  891. ......................................................... *renames*
  892.  
  893. extern "C" int _prx_start(void)
  894. {
  895. while(true)
  896. {
  897. //work?
  898. }
  899. ppu_thread_exit();
  900. return SYS_PRX_RESIDENT;
  901. }
  902. --------------------------------
  903. 1> libc.c
  904. 1> prx.cpp
  905. 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 :)
  906. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  907. ...... Im an idiot... lol... How the hell could I have missed that... Thanks a lot :D
  908.  
  909. Upvote 1
  910. 3141card reacted to this
  911. 0
  912. Lucif3r
  913. Sarcasmaclysmic
  914. Lucif3r
  915. Super Admin
  916.  
  917. Founding Member
  918. 2,459
  919. 2,945 posts
  920. Location: Far away, in a dark cave ,,^..^,,
  921. Posted February 18, 2015
  922. ...
  923.  
  924. #include <cell/sysmodule.h>
  925. void loadStuff(void)
  926. {
  927. int32_t ret;
  928. ret = cellSysmoduleLoadModule( CELL_SYSMODULE_IO );
  929. //a few more calls
  930.  
  931. }
  932. ---------------------------------------
  933. 1> undefined reference to `cellSysmoduleLoadModule' <-- one for each call
  934. 1>Command line : error : L0303: error generating PRX (prx-fixup failed)
  935. 1>Command line : error : L0064: Linking aborted
  936. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  937. sysmodule.h
  938.  
  939. /* function prototypes */
  940. int cellSysmoduleLoadModule(uint16_t id);
  941. using 'extern "C" ' for the loadStuff function doesnt change a thing...
  942.  
  943.  
  944.  
  945. 56331217.jpg
  946.  
  947. Upvote 1
  948. zecoxao reacted to this
  949. 0
  950. zecoxao
  951. Posting Freak
  952. zecoxao
  953. Super Admin
  954.  
  955. Founding Member
  956. Scene Contributor
  957. V.I.P
  958. 1,348
  959. 882 posts
  960. Posted February 18, 2015 (edited)
  961. On 2/18/2015 at 7:28 AM, Lucif3r said:
  962. snip
  963.  
  964. you need to link the library (-l<name of library) in the Makefile
  965.  
  966. 1>Command line : error : L0064: Linking aborted Edited February 18, 2015 by zecoxao
  967. Upvote 1
  968. Lucif3r reacted to this
  969. 0
  970. Lucif3r
  971. Sarcasmaclysmic
  972. Lucif3r
  973. Super Admin
  974.  
  975. Founding Member
  976. 2,459
  977. 2,945 posts
  978. Location: Far away, in a dark cave ,,^..^,,
  979. Posted February 18, 2015
  980. On 2/18/2015 at 7:43 AM, zecoxao said:
  981. you need to link the library (-l<name of library) in the Makefile
  982.  
  983.  
  984.  
  985. lol... Thanks, that fixed it. Weird though, you'd imagine VS would add that automatically... Or maybe Im just too spoiled by C# lol.
  986.  
  987.  
  988.  
  989.  
  990.  
  991. 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:
  992.  
  993. 0
  994. 3141card
  995. Member
  996. 3141card
  997. Founding Member
  998.  
  999. V.I.P
  1000. 172
  1001. 112 posts
  1002. Location: Germany
  1003. Posted February 18, 2015
  1004. Its ok patrick, no need for loading the io module, it is already loaded by vsh. Notice, your plugin is only a thread into
  1005.  
  1006. the vsh process, things like network, io, fs, ... are loaded and running.
  1007.  
  1008.  
  1009.  
  1010. If you would use a pad, look at mysis plugin.
  1011.  
  1012. 0
  1013. Lucif3r
  1014. Sarcasmaclysmic
  1015. Lucif3r
  1016. Super Admin
  1017.  
  1018. Founding Member
  1019. 2,459
  1020. 2,945 posts
  1021. Location: Far away, in a dark cave ,,^..^,,
  1022. Posted February 19, 2015
  1023. Aaand Im stuck again... Similar issue as the last one, except I cant seem to find a fix for this...
  1024.  
  1025. 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...
  1026.  
  1027.  
  1028.  
  1029. 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...
  1030.  
  1031.  
  1032.  
  1033. Ugh... Im getting sick of all these undefined references that are referenced already lol...
  1034.  
  1035. 0
  1036. Frankie
  1037. Member
  1038. Frankie
  1039. Regular Member
  1040.  
  1041. 2
  1042. 14 posts
  1043. Posted February 19, 2015
  1044. On 2/19/2015 at 2:29 PM, Lucif3r said:
  1045. Aaand Im stuck again... Similar issue as the last one, except I cant seem to find a fix for this...
  1046.  
  1047. 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...
  1048.  
  1049.  
  1050.  
  1051. 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...
  1052.  
  1053.  
  1054.  
  1055. Ugh... Im getting sick of all these undefined references that are referenced already lol...
  1056.  
  1057. #define TOC 0x12345678
  1058.  
  1059. struct opd_s
  1060. {
  1061. uint32_t sub;
  1062. uint32_t toc;
  1063. };
  1064.  
  1065. opd_s printf_stub = { 0x12345678, TOC };
  1066. int(*printf)(const char * format, ...) = (int(*)(const char*, ...))&printf_stub;
  1067. You could always do this.
  1068.  
  1069. 0
  1070. Lucif3r
  1071. Sarcasmaclysmic
  1072. Lucif3r
  1073. Super Admin
  1074.  
  1075. Founding Member
  1076. 2,459
  1077. 2,945 posts
  1078. Location: Far away, in a dark cave ,,^..^,,
  1079. Posted February 19, 2015
  1080. Yeah, if only...
  1081.  
  1082. 1>prx.cpp(278,5): error 102: "printf" has already been declared in the current scope
  1083. 1>
  1084. 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")
  1085. time to borrow mr.dutch's wall.... :bash_head:
  1086.  
  1087. 0
  1088. 3141card
  1089. Member
  1090. 3141card
  1091. Founding Member
  1092.  
  1093. V.I.P
  1094. 172
  1095. 112 posts
  1096. Location: Germany
  1097. Posted February 20, 2015
  1098. libio_stub.a has nothing to do with stdio.h or C, its the PS3 IO library, -> pad, mouse, keyboard, remote control, ....
  1099.  
  1100.  
  1101.  
  1102. I try to use the stub libs (I create for vsh exports) in VS project, works fine:
  1103.  
  1104.  
  1105.  
  1106. http://www.mediafire.com/download/dtahiqronu1nk2d/test_plugin.rar
  1107.  
  1108.  
  1109.  
  1110. I hate VS and to work with it, I include only 3 libs for test, If you would add the rest:
  1111.  
  1112.  
  1113.  
  1114. Into the export headers you have C functions, so you must use extern "C"
  1115.  
  1116. or you get name mangling trouble. Regarding classes, look at mysis code.
  1117.  
  1118.  
  1119.  
  1120. Using this export libs is the most comfortable way to use vsh exports, if you need
  1121.  
  1122. e.g. printf(), simply use it. :)
  1123.  
  1124. Upvote 1
  1125. Lucif3r reacted to this
  1126. 0
  1127. Lucif3r
  1128. Sarcasmaclysmic
  1129. Lucif3r
  1130. Super Admin
  1131.  
  1132. Founding Member
  1133. 2,459
  1134. 2,945 posts
  1135. Location: Far away, in a dark cave ,,^..^,,
  1136. Posted February 20, 2015
  1137. 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?)
  1138.  
  1139.  
  1140.  
  1141. 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)?
  1142.  
  1143.  
  1144.  
  1145. 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
  1146.  
  1147. I think Ive bitten off more than I can chew :/
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153. Thanks for all your help by the way, really appreciate it :)
  1154.  
  1155.  
  1156.  
  1157. edit: actually, you could help me with one more thing if you want. :)
  1158.  
  1159.  
  1160.  
  1161. 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).
  1162.  
  1163. 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").
  1164.  
  1165. Upvote 1
  1166. 3141card reacted to this
  1167. 0
  1168. 3141card
  1169. Member
  1170. 3141card
  1171. Founding Member
  1172.  
  1173. V.I.P
  1174. 172
  1175. 112 posts
  1176. Location: Germany
  1177. Posted February 20, 2015
  1178. #include <header.h> its a standard header into systemdir, if you write e.g. a own -> #include "header.h".
  1179.  
  1180.  
  1181.  
  1182. Quote
  1183.  
  1184.  
  1185. But why did this work,...
  1186.  
  1187. this prx coding is not like normal coding, again, the plugin main thread is only a thread into the vsh process of ps3.
  1188.  
  1189.  
  1190.  
  1191. There is no way for use e.g. standard C things like memset(). But the vsh proc export many functions, and
  1192.  
  1193. we can use this exports.
  1194.  
  1195.  
  1196.  
  1197. Quote
  1198.  
  1199.  
  1200. (void*&)(vshmain_981D7E9F) = (void*)((int)getNIDfunc("vshmain",0x981D7E9F));",
  1201.  
  1202.  
  1203.  
  1204. Its a functions pointer, an addr into vsh code where the code of an function (e.g. one of the exports) starts.
  1205.  
  1206. mysis getNIDfunc() get this addr by module name ("vshmain") and node-id (0x981D7E9F).
  1207.  
  1208. If you call this addr with the proper args, this code/function will be exec.
  1209.  
  1210.  
  1211.  
  1212. Quote
  1213.  
  1214.  
  1215. ..., but I dont understand how you find out you should use e.g "981D7E9F"...
  1216.  
  1217. I use e.g. the old IDA scripts from kakaroto, this scripts identify a many, the rest must be disassembled, e.g. by mysis.
  1218.  
  1219. http://www.psdevwiki.com/ps3/VSH#Exports
  1220.  
  1221.  
  1222.  
  1223. A many gcm functions was easy to identify by method codes. Syscalls, error-codes and strings are allways helpfull.
  1224.  
  1225. The rest is simply reversing, its like a puzzle, thats fun.
  1226.  
  1227.  
  1228.  
  1229. The plugin stuff is maybe not the best start into a new lang, :) And yes, names are better than nid's.
  1230.  
  1231.  
  1232.  
  1233. Upvote 3
  1234. Lucif3r, mysis and zecoxao reacted to this
  1235. 0
  1236. 3141card
  1237. Member
  1238. 3141card
  1239. Founding Member
  1240.  
  1241. V.I.P
  1242. 172
  1243. 112 posts
  1244. Location: Germany
  1245. Posted February 20, 2015
  1246. char msg[128]; // a string buffer
  1247. int val = 666;
  1248.  
  1249. sprintf(msg, // buffer to hold the result
  1250. "number %d", // string format
  1251. val); // var
  1252. http://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261. Lucif3r
  1262. Sarcasmaclysmic
  1263. Lucif3r
  1264. Super Admin
  1265.  
  1266. Founding Member
  1267. 2,459
  1268. 2,945 posts
  1269. Location: Far away, in a dark cave ,,^..^,,
  1270. Posted February 20, 2015
  1271. Yes, I know that already :).
  1272.  
  1273. 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.
  1274.  
  1275. 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?
  1276.  
  1277. Worth pointing out is that tty_write can keep spamming the console forever with a 100ms delay between each loop...
  1278.  
  1279. 0
  1280. 3141card
  1281. Member
  1282. 3141card
  1283. Founding Member
  1284.  
  1285. V.I.P
  1286. 172
  1287. 112 posts
  1288. Location: Germany
  1289. Posted February 20, 2015
  1290. Its bad to say something without to see the code.
  1291.  
  1292.  
  1293.  
  1294. Give out msg's only if something is hapen, and not continously into a while-loop
  1295.  
  1296.  
  1297.  
  1298. The memory you have into your plugin thread is = the stack size of your plugin main thread.
  1299.  
  1300. if you need more, for whatever, use sys_memory_allocate() ...
  1301.  
  1302.  
  1303.  
  1304. If you have e.g. char msg[128]; into your main, than yes, without freeing, your stack memory runs out.
  1305.  
  1306. put such things never into a while loop. You need only one string buffer to hold you msg, not each round
  1307.  
  1308. a new.
  1309.  
  1310. 0
  1311. Lucif3r
  1312. Sarcasmaclysmic
  1313. Lucif3r
  1314. Super Admin
  1315.  
  1316. Founding Member
  1317. 2,459
  1318. 2,945 posts
  1319. Location: Far away, in a dark cave ,,^..^,,
  1320. Posted February 21, 2015
  1321. Mmm, heres a snippet of the code.
  1322.  
  1323. while(true)
  1324. {
  1325. sys_timer_usleep(2000); //tried different delays
  1326. if(cellPadGetData(0, &data) == CELL_PAD_OK && data.len > 0)
  1327. {
  1328. if(data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] > 0)// & CELL_PAD_CTRL_R2)
  1329. {
  1330. //printf("moo %02d ", data.button[CELL_PAD_BTN_OFFSET_PRESS_R2]);
  1331. sys_timer_usleep(100); //tried different delays here as well
  1332. dbprint("char test ");
  1333. //printf("char test1 ");
  1334. }
  1335. }
  1336. }
  1337. 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).
  1338.  
  1339. 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).
  1340.  
  1341. 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.
  1342.  
  1343. 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
  1344.  
  1345.  
  1346.  
  1347. -----
  1348.  
  1349.  
  1350.  
  1351. 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
  1352.  
  1353. 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...).
  1354.  
  1355.  
  1356.  
  1357. 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 :/).
  1358.  
  1359. 0
  1360. 3141card
  1361. Member
  1362. 3141card
  1363. Founding Member
  1364.  
  1365. V.I.P
  1366. 172
  1367. 112 posts
  1368. Location: Germany
  1369. Posted February 21, 2015
  1370. sys_timer_usleep(100); is nothing
  1371.  
  1372.  
  1373.  
  1374. 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)
  1375.  
  1376. or it is not posible to select proper, too fast.
  1377.  
  1378.  
  1379.  
  1380. And I use CEX, so I have no tty syscalls.
  1381.  
  1382.  
  1383.  
  1384. How look your dbprint() ?
  1385.  
  1386. 0
  1387. Lucif3r
  1388. Sarcasmaclysmic
  1389. Lucif3r
  1390. Super Admin
  1391.  
  1392. Founding Member
  1393. 2,459
  1394. 2,945 posts
  1395. Location: Far away, in a dark cave ,,^..^,,
  1396. Posted February 21, 2015
  1397. I posted it earlier, but here it is again(you even commented about it, about the return etc :>);
  1398.  
  1399. int dbprint(const char * text, ...)
  1400. {
  1401. uint32_t len;
  1402. system_call_4(403, 0, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  1403. return 1;
  1404.  
  1405. }
  1406. Btw, 100ms is, last I checked, 1/10th of a second ;)
  1407.  
  1408. 0
  1409. 3141card
  1410. Member
  1411. 3141card
  1412. Founding Member
  1413.  
  1414. V.I.P
  1415. 172
  1416. 112 posts
  1417. Location: Germany
  1418. Posted February 21, 2015
  1419. u(micro)sleep(), not milli ;) 1/10 sec = 100 millisecond = 100000 microseconds
  1420.  
  1421.  
  1422.  
  1423. int dbprint(const char * text, ...) the ... is useless, int dbprint(const char * text)
  1424.  
  1425.  
  1426.  
  1427. I test some things...
  1428.  
  1429. 0
  1430. Lucif3r
  1431. Sarcasmaclysmic
  1432. Lucif3r
  1433. Super Admin
  1434.  
  1435. Founding Member
  1436. 2,459
  1437. 2,945 posts
  1438. Location: Far away, in a dark cave ,,^..^,,
  1439. Posted February 21, 2015
  1440. Thats funny, because usleep(2000) results in the exact same delay as sleep(2)? :s
  1441.  
  1442. 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.
  1443.  
  1444.  
  1445.  
  1446. On 2/21/2015 at 4:23 AM, 3141card said:
  1447. int dbprint(const char * text, ...) the ... is useless, int dbprint(const char * text)
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453. 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.
  1454.  
  1455. 0
  1456. 3141card
  1457. Member
  1458. 3141card
  1459. Founding Member
  1460.  
  1461. V.I.P
  1462. 172
  1463. 112 posts
  1464. Location: Germany
  1465. Posted February 21, 2015
  1466. I think this it you search for:
  1467.  
  1468. #include <stdio.h>
  1469. #include <stdarg.h> // for va_list, va_start, va_arg, va_end
  1470.  
  1471. ...
  1472.  
  1473. extern "C" void dbprint(const char * text, ...)
  1474. {
  1475. uint32_t len;
  1476. char buf[0x200];
  1477. va_list arg;
  1478.  
  1479. va_start(arg, text);
  1480. vsnprintf(buf, sizeof(buf), text, arg);
  1481. va_end(arg);
  1482.  
  1483. system_call_4(403, 0, (uint64_t) buf, strlen(buf), (uint64_t) &len); //tty write
  1484. }
  1485.  
  1486. ...
  1487.  
  1488. dbprint("test: %d", 666); // output: test: 666
  1489. Upvote 1
  1490. Lucif3r reacted to this
  1491. 0
  1492. Lucif3r
  1493. Sarcasmaclysmic
  1494. Lucif3r
  1495. Super Admin
  1496.  
  1497. Founding Member
  1498. 2,459
  1499. 2,945 posts
  1500. Location: Far away, in a dark cave ,,^..^,,
  1501. Posted February 21, 2015
  1502. 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()).
  1503.  
  1504.  
  1505.  
  1506. Heres the log, maybe you can make some sense of it lol:
  1507.  
  1508. Reveal hidden contents
  1509. 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
  1510.  
  1511.  
  1512. And this is how it should look when everything's fine:
  1513.  
  1514. Game: game exec processID = [0x01010200]
  1515. HAI!
  1516. Thread created
  1517. Im ready!
  1518. 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.
  1519.  
  1520. 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. :(
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526. Edit: And yes, this IS exactly what Im looking for and been trying to pull off for quite a while now lol
  1527.  
  1528. 0
  1529. 3141card
  1530. Member
  1531. 3141card
  1532. Founding Member
  1533.  
  1534. V.I.P
  1535. 172
  1536. 112 posts
  1537. Location: Germany
  1538. Posted February 21, 2015
  1539. No idea, I never use tty.
  1540.  
  1541.  
  1542.  
  1543. Maybe you can try a other channel than 0, 0 to 2 are system reserved, 3 to 15 are for user.
  1544.  
  1545.  
  1546.  
  1547. Maybe this fix the prob.
  1548.  
  1549. Upvote 1
  1550. Lucif3r reacted to this
  1551. 0
  1552. Lucif3r
  1553. Sarcasmaclysmic
  1554. Lucif3r
  1555. Super Admin
  1556.  
  1557. Founding Member
  1558. 2,459
  1559. 2,945 posts
  1560. Location: Far away, in a dark cave ,,^..^,,
  1561. Posted February 21, 2015
  1562. Unfortunately, changing channel did jack-squat, still same shit... ughhhhhhhhhhhh *flips table*
  1563.  
  1564. 0
  1565. Lucif3r
  1566. Sarcasmaclysmic
  1567. Lucif3r
  1568. Super Admin
  1569.  
  1570. Founding Member
  1571. 2,459
  1572. 2,945 posts
  1573. Location: Far away, in a dark cave ,,^..^,,
  1574. Posted February 21, 2015
  1575. vsnprintf(buf, sizeof(buf), text, arg);
  1576.  
  1577. 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
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583. 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.
  1584.  
  1585. 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...
  1586.  
  1587. 0
  1588. 3141card
  1589. Member
  1590. 3141card
  1591. Founding Member
  1592.  
  1593. V.I.P
  1594. 172
  1595. 112 posts
  1596. Location: Germany
  1597. Posted February 21, 2015
  1598. Sry my friend, I forget something into the C++ plugin. And btw, it can't be vsnprintf().
  1599.  
  1600.  
  1601.  
  1602. There is a usleep(70000) at the end of the main while of the cobra test plugin,
  1603.  
  1604. the reason for this delay is the usage of cellPadGetData(0, &data).
  1605.  
  1606.  
  1607.  
  1608. If our plugin ask, without delay, for pad data for pad port 0, than the vsh process
  1609.  
  1610. can't ask, therefor pad bug into xmb. Our main while block the system:
  1611.  
  1612.  
  1613.  
  1614. lv2(2): System Warning : busy loop detected (our main while)
  1615.  
  1616.  
  1617.  
  1618. I use for a long time no own pad data struct or cellPadGetData() into my C plugins.
  1619.  
  1620. I found it idiotic, to ask for data which are already here. The vsh process have a own
  1621.  
  1622. pad data struct, so why ask a second time for data which are already exist.
  1623.  
  1624.  
  1625.  
  1626. Therefore I forget it, add this delay at the end of your main while for proper sync:
  1627.  
  1628. ...
  1629. while(true)
  1630. {
  1631. if(cellPadGetData(0, &data) == CELL_PAD_OK && data.len > 0)
  1632. {
  1633. bool start = (data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START);
  1634.  
  1635. if(start)
  1636. {
  1637. exit_thread = true;
  1638. vshtask_notify("plugin stop...");
  1639. }
  1640. }
  1641.  
  1642. if(exit_thread == true)
  1643. ppu_thread_exit();
  1644.  
  1645. sys_timer_usleep(70000); // pad get data sync delay
  1646. } // main while end
  1647. 0
  1648. Lucif3r
  1649. Sarcasmaclysmic
  1650. Lucif3r
  1651. Super Admin
  1652.  
  1653. Founding Member
  1654. 2,459
  1655. 2,945 posts
  1656. Location: Far away, in a dark cave ,,^..^,,
  1657. Posted February 21, 2015
  1658. FIXED IT! all by myself lol(see, I can do something on my own!). So this is how I had to do it:
  1659.  
  1660. //inside while(true), after checking pad data etc
  1661. char f[0x40];
  1662. snprintf(f,100,"moo %02d ", data.button[CELL_PAD_BTN_OFFSET_PRESS_R2]);
  1663. dbprint(f);
  1664. sys_timer_usleep(100000);
  1665. f[sizeof(f) / sizeof(f[0])] = '\0';
  1666. //rinse and repeat
  1667. Output:
  1668.  
  1669. Im ready!
  1670. moo 255 moo 255 moo 255 moo 255 moo 255 moo 255 moo 255 moo 255 moo 100 moo 127 moo 66 mo
  1671. 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
  1672. 55 moo 255 moo 122 moo 108 moo 190 moo 255 moo 255
  1673. Im going to tidy it up so it looks better... atm its a mess lol.
  1674.  
  1675. 0
  1676. 3141card
  1677. Member
  1678. 3141card
  1679. Founding Member
  1680.  
  1681. V.I.P
  1682. 172
  1683. 112 posts
  1684. Location: Germany
  1685. Posted February 21, 2015
  1686. sys_timer_usleep(100000); this is the fix, a delay for non blocking the vsh
  1687.  
  1688. 0
  1689. Lucif3r
  1690. Sarcasmaclysmic
  1691. Lucif3r
  1692. Super Admin
  1693.  
  1694. Founding Member
  1695. 2,459
  1696. 2,945 posts
  1697. Location: Far away, in a dark cave ,,^..^,,
  1698. Posted February 21, 2015
  1699. Ive had that all a long though, well, since you said that thing about usleep a couple of posts back.
  1700.  
  1701. ----
  1702.  
  1703. 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 :)).
  1704.  
  1705.  
  1706.  
  1707. With that out of the way, I can actually start trying to MAKE something out of this lol
  1708.  
  1709. Upvote 1
  1710. 3141card reacted to this
  1711. 0
  1712. 3141card
  1713. Member
  1714. 3141card
  1715. Founding Member
  1716.  
  1717. V.I.P
  1718. 172
  1719. 112 posts
  1720. Location: Germany
  1721. Posted February 21, 2015
  1722. Ok, than learn, try out things and release nice stuff in future :)
  1723.  
  1724. Upvote 1
  1725. Lucif3r reacted to this
  1726. 0
  1727. Lucif3r
  1728. Sarcasmaclysmic
  1729. Lucif3r
  1730. Super Admin
  1731.  
  1732. Founding Member
  1733. 2,459
  1734. 2,945 posts
  1735. Location: Far away, in a dark cave ,,^..^,,
  1736. Posted February 21, 2015
  1737. 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...
  1738.  
  1739. 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.
  1740.  
  1741. 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*) :(
  1742.  
  1743.  
  1744.  
  1745. 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.
  1746.  
  1747.  
  1748.  
  1749. 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).
  1750.  
  1751. void dbprint(const char * text, ...)
  1752. {
  1753. uint32_t len;
  1754. va_list arg;
  1755. char f[0x40];
  1756. va_start(arg, text);
  1757. int g = va_arg(arg, int);
  1758. sprintf(f,text, g);
  1759. va_end(arg);
  1760. system_call_4(403, 3, (uint64_t) f, strlen(f), (uint64_t) &len); //tty write
  1761. f[sizeof(f) / sizeof(f[0])] = '\0';
  1762. }
  1763. 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....
  1764.  
  1765. 0
  1766. Lucif3r
  1767. Sarcasmaclysmic
  1768. Lucif3r
  1769. Super Admin
  1770.  
  1771. Founding Member
  1772. 2,459
  1773. 2,945 posts
  1774. Location: Far away, in a dark cave ,,^..^,,
  1775. Posted February 21, 2015
  1776. First experiment = success! Its not much, just remapped the controller to do other stuff when buttons are pressed...
  1777.  
  1778.  
  1779.  
  1780. Still, its a start!
  1781.  
  1782. 9q1Qe7i.png
  1783.  
  1784. Upvote 2
  1785. sandungas and TheDarkprogramer reacted to this
  1786. 0
  1787. 3141card
  1788. Member
  1789. 3141card
  1790. Founding Member
  1791.  
  1792. V.I.P
  1793. 172
  1794. 112 posts
  1795. Location: Germany
  1796. Posted February 22, 2015
  1797. I switch to DEX to for test it, the code I post works fine.
  1798.  
  1799. prx: no var's
  1800. prx: 666
  1801. prx: 888 0x1234AABB
  1802. prx: 0.967000
  1803. prx: r2 pressed
  1804. prx: r2 pressed
  1805. prx: r2 pressed
  1806. prx: r2 pressed
  1807. prx: r2 pressed
  1808. prx: r2 pressed
  1809. prx: r2 pressed
  1810. prx: r2 pressed
  1811. prx: r2 pressed
  1812. prx: r2 pressed
  1813. prx: r2 pressed
  1814. prx: start pressed
  1815. no probs with dbprintf():
  1816.  
  1817. extern "C" void dbprint(const char * text, ...)
  1818. {
  1819. uint32_t len;
  1820. char buf[0x200];
  1821. va_list arg;
  1822.  
  1823. va_start(arg, text);
  1824. vsnprintf(buf, sizeof(buf), text, arg);
  1825. va_end(arg);
  1826.  
  1827. //vshtask_notify(buf);
  1828.  
  1829. system_call_4(403, 0, (uint64_t) buf, strlen(buf), (uint64_t) &len); //tty write
  1830.  
  1831. }
  1832.  
  1833. ...
  1834.  
  1835. // into main thread
  1836.  
  1837. dbprint("prx: no var's\n");
  1838. dbprint("prx: %d\n", 666);
  1839. dbprint("prx: %d 0x%08X\n", 888, 0x1234AABB);
  1840. dbprint("prx: %f\n", 0.967);
  1841.  
  1842. ...
  1843. // into main while
  1844.  
  1845. if(start)
  1846. {
  1847. exit_thread = true;
  1848. dbprint("prx: start pressed\n");
  1849. sys_timer_usleep(300000);
  1850. }
  1851.  
  1852. if(r2)
  1853. {
  1854. dbprint("prx: r2 pressed\n");
  1855. sys_timer_usleep(300000);
  1856. }
  1857. 0
  1858. Lucif3r
  1859. Sarcasmaclysmic
  1860. Lucif3r
  1861. Super Admin
  1862.  
  1863. Founding Member
  1864. 2,459
  1865. 2,945 posts
  1866. Location: Far away, in a dark cave ,,^..^,,
  1867. Posted February 22, 2015
  1868. Funny... Any theories why it goes completely emo for me?
  1869.  
  1870. 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...
  1871.  
  1872.  
  1873.  
  1874. 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).
  1875.  
  1876.  
  1877.  
  1878. This is how I do it now anyway.
  1879. void dbprintf(const char * text, ...)
  1880. //'extern "C" ' or not doesnt make a difference, and your function causes the exact same issues.
  1881. //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^^
  1882. {
  1883. uint32_t len;
  1884. va_list arg;
  1885. char f[0x40];
  1886. va_start(arg, text);
  1887. int g = va_arg(arg, int);
  1888. sprintf(f,text, g);
  1889. va_end(arg);
  1890. system_call_4(403, 3, (uint64_t) f, strlen(f), (uint64_t) &len); //tty write
  1891. f[sizeof(f) / sizeof(f[0])] = '\0';
  1892. }
  1893. void dbprint(const char * text, ...)
  1894. {
  1895. uint32_t len;
  1896. system_call_4(403, 3, (uint64_t) text, strlen(text), (uint64_t) &len); //tty write
  1897. }
  1898.  
  1899. //main
  1900. while(true)
  1901. {
  1902. if(cellPadGetData(0, &data) == CELL_PAD_OK && data.len > 0)
  1903. {
  1904. if(data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] > 0)
  1905. {
  1906. dbprintf("R2; %d pressure ", data.button[CELL_PAD_BTN_OFFSET_PRESS_R2]);
  1907. data.button[3] = CELL_PAD_CTRL_CIRCLE;
  1908. cellPadLddDataInsert( vPadHandle, &data );
  1909. dbprint("Circle was pressed!\n");
  1910. sys_timer_sleep(1); //going to adjust this sleep obviously, theres no point to have a whole second delay here.
  1911. //my awesome R2 "remapper", aint it a beauty? lol........ its shit I know :(
  1912. }
  1913. }
  1914. }
  1915.  
  1916.  
  1917.  
  1918. Oh, and again, thank you for all your help. If it wasnt for your help, I'd given up ages ago :P
  1919.  
  1920. Upvote 1
  1921. 3141card reacted to this
  1922. 0
  1923. 3141card
  1924. Member
  1925. 3141card
  1926. Founding Member
  1927.  
  1928. V.I.P
  1929. 172
  1930. 112 posts
  1931. Location: Germany
  1932. Posted February 22, 2015 (edited)
  1933. No idea :(
  1934.  
  1935.  
  1936.  
  1937. Iam furthermore on 4.46 rebug, make norbin dump with toolbox, convert with cec2dex, flash it with mm, change lv2 kernel in toolbox.
  1938.  
  1939.  
  1940.  
  1941. 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)
  1942.  
  1943.  
  1944.  
  1945. and vsnprintf() is from stdc_lib not sys_vsnprintf() aka sysPrxForUser_0618936B.
  1946.  
  1947.  
  1948.  
  1949. And no prob, its a nice hobby :)
  1950.  
  1951.  
  1952.  
  1953. EDIT: I think not is a versions prob, new sdks have often impro. of highlevel stuff like thread managment
  1954.  
  1955. and such things, but simply lowlevel things like tty...
  1956.  
  1957. Edited February 22, 2015 by 3141card
  1958. 0
  1959. Lucif3r
  1960. Sarcasmaclysmic
  1961. Lucif3r
  1962. Super Admin
  1963.  
  1964. Founding Member
  1965. 2,459
  1966. 2,945 posts
  1967. Location: Far away, in a dark cave ,,^..^,,
  1968. Posted February 22, 2015
  1969. 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 :)
  1970.  
  1971. 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 :)
  1972.  
  1973. 0
  1974. 3141card
  1975. Member
  1976. 3141card
  1977. Founding Member
  1978.  
  1979. V.I.P
  1980. 172
  1981. 112 posts
  1982. Location: Germany
  1983. Posted February 22, 2015
  1984. I use only delays to prevent to fast inputs, works fine for me, even in complex psl1ght progs
  1985.  
  1986. with menus.
  1987.  
  1988.  
  1989.  
  1990. What you search for need status variables, something like old_pad, new_pad...
  1991.  
  1992.  
  1993.  
  1994. sure you will find something in the sdk samples, e.g. sysutil/, I never need it.
  1995.  
  1996. 0
  1997. Lucif3r
  1998. Sarcasmaclysmic
  1999. Lucif3r
  2000. Super Admin
  2001.  
  2002. Founding Member
  2003. 2,459
  2004. 2,945 posts
  2005. Location: Far away, in a dark cave ,,^..^,,
  2006. Posted February 22, 2015
  2007. 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)...
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024. therifboy
  2025. Newbie
  2026. therifboy
  2027. New Member
  2028.  
  2029. 0
  2030. 4 posts
  2031. Posted February 22, 2015 (edited)
  2032. 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)
  2033.  
  2034.  
  2035.  
  2036. You'll have a new import stub in your plugin.
  2037. http://i.imgur.com/NfKAMAV.png
  2038.  
  2039.  
  2040.  
  2041. VSH exports that same stub but under a different name.
  2042. http://i.imgur.com/lLrEpa7.png
  2043.  
  2044.  
  2045. 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.
  2046.  
  2047.  
  2048.  
  2049. edit:
  2050.  
  2051. f[sizeof(f) / sizeof(f[0])] = '\0';
  2052. should be
  2053.  
  2054. f[sizeof(f) / sizeof(f[0]) - 1] = '\0'; Edited February 22, 2015 by therifboy
  2055. 0
  2056. 3141card
  2057. Member
  2058. 3141card
  2059. Founding Member
  2060.  
  2061. V.I.P
  2062. 172
  2063. 112 posts
  2064. Location: Germany
  2065. Posted February 22, 2015
  2066. I mean samples like recording, this samples needs a pad, look at this code. :)
  2067.  
  2068. Pad events are only in xmb or ingame-xmb, not ingame, thats normal, I use a other way:
  2069.  
  2070.  
  2071.  
  2072. CellPadData *getPadDataStruct()
  2073. {
  2074. uint64_t ret = 0;
  2075. uint32_t start = 0x00708B10; // start .bss segment
  2076. int32_t size = 0x00049010; // size .bss segment
  2077.  
  2078.  
  2079. while(start != (start + size)){
  2080. if((ret = *(uint64_t*)start) == 0x0000004600000046ULL)
  2081. return (CellPadData*)(start - 0x8C);
  2082. start+=8;
  2083. }
  2084.  
  2085. return (CellPadData*)0;
  2086. }
  2087.  
  2088. ...
  2089.  
  2090. //CellPadData data;
  2091. CellPadData *data = getPadDataStruct();
  2092.  
  2093. while(true)
  2094. {
  2095. // ask for data of the vsh pad data struct, no need for a own
  2096. if(data->len > 0)
  2097. {
  2098. if(data->button[2] & CELL_PAD_CTRL_START)
  2099. {
  2100. exit_thread = true;
  2101. dbprint("prx: start pressed\n");
  2102. sys_timer_usleep(300000);
  2103. }
  2104.  
  2105. if(data->button[3] & CELL_PAD_CTRL_R2)
  2106. {
  2107. dbprint("prx: r2 pressed\n");
  2108. sys_timer_usleep(300000);
  2109. }
  2110. }
  2111.  
  2112. if(exit_thread == true)
  2113. ppu_thread_exit();
  2114.  
  2115. sys_timer_usleep(70000);
  2116. }
  2117. the vsh_pad_data are available all the time, not only in xmb and ingame xmb,
  2118.  
  2119. but there is no warranty that it is generic. The search value is from a other pad object, maybe not ever
  2120.  
  2121. direct behind vsh_pad_data or a other value.
  2122.  
  2123.  
  2124.  
  2125. Hi therifboy :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement