Hacking drawString F R E E Z E

hugofestA

Well-Known Member
OP
Newcomer
Joined
Feb 10, 2016
Messages
52
Trophies
0
Age
32
Location
mast:3rw0rld
Website
oddity.comxa.com
XP
101
Country
Hungary
Hi!
I have problems with drawstring(yes, again).
The problem is the same, so:
Code:
fillScreen(0,0,0,0);
drawString(1, 1, "Hello World! we haxd u");
flipBuffers();
After running this code, Wii U freezes, the .mp4 loading icon freezes, and the GamePad freezes too.
I tried with my custom library, same problem:
Code:
//flipBuffers(int bufferNum)
//This is for "executing drawing to the screen"
//Think about it like a piece of paper
//The program writes it to the bottom of the paper, so you need to flip it to see it
//There are 2 pieces of paper: 1 for the GamePad, 1 for the TV.
//bufferNums:
//TV: 0
//GamePad: 1
void flipBuffers(unsigned int bufferNum){
  //"Including" coreinit module
  unsigned int coreinit_handle;
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
  //Setting functions
  void(*DCFlushRange)(void *buffer, uint32_t length);
unsigned int(*OSScreenFlipBuffersEx)(unsigned int bufferNum);
OSDynLoad_FindExport(coreinit_handle, 0, "DCFlushRange", &DCFlushRange);
OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenFlipBuffersEx", &OSScreenFlipBuffersEx);
unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum);
OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx);
  //Grabbing the buffer size for the screen in bufferNum
  int buf_size = OSScreenGetBufferSizeEx(bufferNum);
  //Flushing cache
  DCFlushRange((void *)0xF4000000, buf_size);
  //Flipping the buffer
  OSScreenFlipBuffersEx(bufferNum);
}

//drawstring(unsigned int bufferNum, int x, int line, char * string)
//Drawing a string
//bufferNum = buffer number of display
//x = position on x axis
//line = line on y axis
//string = text to print
void drawString(unsigned int bufferNum, int x, int line, char * string)
{
  //"Including" coreinit module
unsigned int coreinit_handle;
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
  //Setting functions
unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
  //Drawing the string
OSScreenPutFontEx(bufferNum, x, line, string);
}
//fillScreen(unsigned int bufferNum, char r,char g,char b,char a)
//Filling screen
//bufferNum = buffer number of display
//r = amount of red
//g = amount of green
//b = amount of blue
//a = ???(maybe darkness)
void fillScreen(unsigned int bufferNum, char r,char g,char b,char a)
{
  //"Including" coreinit module
unsigned int coreinit_handle;
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
  //Setting functions
unsigned int(*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp);
OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenClearBufferEx", &OSScreenClearBufferEx);
  //Crafting a number from r, g, b and a
uint32_t num = (r << 24) | (g << 16) | (b << 8) | a;
  //Filling screen (clearing buffer "with" a custom color)
OSScreenClearBufferEx(bufferNum, num);
}
Can somebody help?
Thanks,
hugo

Edit: SOLVED!!!
 
Last edited by hugofestA,

NWPlayer123

Well-Known Member
Member
Joined
Feb 17, 2012
Messages
2,642
Trophies
0
Location
The Everfree Forest
XP
6,693
Country
United States
Oh, I found your error, not enough arguments. You forgot the bufferNum, drawString(0, 1, 1, "Hello World! we haxd u"); //TV, at pos 1, 1
I'd also include types.h and update your drawString types
http://wiiubrew.org/wiki/Coreinit.rpl#Screen
Code:
void drawString(int bufferNum, uint32_t posX, uint32_t posY, const char *string)
{
    uint32_t coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); //Get handle
    void (*OSScreenPutFontEx)(int bufferNum, uint32_t posX, uint32_t posY, const char *string); //Define
    OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx); //Obtain
    OSScreenPutFontEx(bufferNum, posX, posY, string); //Call
}
 

hugofestA

Well-Known Member
OP
Newcomer
Joined
Feb 10, 2016
Messages
52
Trophies
0
Age
32
Location
mast:3rw0rld
Website
oddity.comxa.com
XP
101
Country
Hungary
Oh, I found your error, not enough arguments. You forgot the bufferNum, drawString(0, 1, 1, "Hello World! we haxd u"); //TV, at pos 1, 1
I'd also include types.h and update your drawString types
http://wiiubrew.org/wiki/Coreinit.rpl#Screen
Code:
void drawString(int bufferNum, uint32_t posX, uint32_t posY, const char *string)
{
    uint32_t coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); //Get handle
    void (*OSScreenPutFontEx)(int bufferNum, uint32_t posX, uint32_t posY, const char *string); //Define
    OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx); //Obtain
    OSScreenPutFontEx(bufferNum, posX, posY, string); //Call
}
No:
Code:
void drawString(int x, int line, char * string)
{
 unsigned int coreinit_handle;
 OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
 unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
 OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
 OSScreenPutFontEx(0, x, line, string);
 OSScreenPutFontEx(1, x, line, string);
}
 

NWPlayer123

Well-Known Member
Member
Joined
Feb 17, 2012
Messages
2,642
Trophies
0
Location
The Everfree Forest
XP
6,693
Country
United States
No:
Code:
void drawString(int x, int line, char * string)
{
unsigned int coreinit_handle;
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
OSScreenPutFontEx(0, x, line, string);
OSScreenPutFontEx(1, x, line, string);
}
That's a different snippet than in the OP, but then I don't see what else is wrong :\
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: @Psionic Roshambo, Shouldn't preservation be legal tho?