How to hook sceGuFinish???

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
iceman755
Posts: 30
Joined: Mon Jul 21, 2008 1:12 am

How to hook sceGuFinish???

Post by iceman755 »

After reading a lot about blitting on the XMB, I got that I have to hook sceGuFinish to do Gu things over the XMB, but No matter what I do, I can't get that function hooked.

I have two conclusion for my issue: the first one is that I'm using wrong module and library names (the NID for 5.00 was given by Silverspring in a post over this forum). The second conclusion is, if module and library names are correct, then maybe sceGuFinish is never call by the XMB.

This is the code I'm using to test if the function is being hooked:

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspgu.h>
#include <systemctrl.h>
#include <stdio.h>
#include <string.h>

PSP_MODULE_INFO&#40;"test", 0x1000, 1, 0&#41;;

void myGuFinish&#40;&#41;
	&#123;
		int k1 = pspSdkSetK1&#40;0&#41;;
		
		sceGuClearColor&#40;GU_RGBA&#40;255, 255, 255, 255&#41;&#41;;
		
		sceGuClear&#40;GU_COLOR_BUFFER_BIT&#41;;
		
		pspSdkSetK1&#40;k1&#41;;
		
		sceGuFinish&#40;&#41;;
	&#125;

STMOD_HANDLER previous = NULL;
u32 orgaddr;

int OnModuleStart&#40;SceModule2 *mod&#41;
	&#123;	
		if &#40;strcmp&#40;mod->modname, "scePaf_Module"&#41; == 0&#41;
			&#123;	
				orgaddr=sctrlHENFindFunction&#40;"scePaf_Module", "scePaf", 0x4170FB8F&#41;;
				sctrlHENPatchSyscall&#40;orgaddr, myGuFinish&#41;;
	 
				sceKernelDcacheWritebackAll&#40;&#41;;
				sceKernelIcacheClearAll&#40;&#41;;
			&#125;
   
		if &#40;!previous&#41;
			return 0;
   
		return previous&#40;mod&#41;;
	&#125;

int module_start&#40;SceSize args, void *argp&#41;
&#123;	
	previous = sctrlHENSetStartModuleHandler&#40;OnModuleStart&#41;;
	
	return 0;
&#125;
I'm hopping this code to clear the screen in white but nothing happens, no white screen, no errors, no crash, nothing.
"Libera eas de ore leonis, ne absorbeat eas tartarus, ne cadant in obscurum"
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Post by crazyc »

You can't because sceGuFinish is not a kernel function. It only places a finish command in the display list. Try hooking sceGeListUpdateStallAddr instead.
ab5000
Posts: 74
Joined: Tue May 06, 2008 2:37 am

Post by ab5000 »

yes, you can hook a user mode function, but not in that way. search "easy hook example user kernel" in this forum.

Code: Select all

%&#58;include<stdio.h>
int _&#40;int __,int ___,int ____,int _____&#41;
<%for&#40;;____<___;_____=_____*__,____++&#41;;
return _____;%>main&#40;&#41;<%printf
&#40;"%d\n",_&#40;2,5,0,1&#41;&#41;;%>
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Post by crazyc »

ab5000 wrote:yes, you can hook a user mode function, but not in that way. search "easy hook example user kernel" in this forum.
If he did want to override sceGuFinish, he could just change the order by linking his function before libgu, but that wouldn't enable him to do what he said he wanted.
Post Reply