Homebrew Official 5.5.X ELF Loader

NWPlayer123

Well-Known Member
OP
Member
Joined
Feb 17, 2012
Messages
2,642
Trophies
0
Location
The Everfree Forest
XP
6,693
Country
United States
Does anyone know the maximum allocatable size we can get from heap ?
I have to allocate a buffer to copy an unsigned char array of about 990 000 rows . When I use MEMAllocFromHeapEx function it crashes, so i assume it's not possible to allocate a buffer that big...
If it's not possible, how can i allocate directly from the stack (and what is the stack adress range for the elf loader) ?.

I have another question, when i allocate memory for a struct, does it allocate memory for struct pointers placed inside the struct (as in linked list for ex) ?
Probably not unless you use u32 MEMGetBaseHeapHandle(int arena); void* MEMAllocFromExpHeapEx(u32 *handle, u32 size, int alignment); Be sure to check if the alloc value returned is NULL.
EDIT: whoops, changed something, need to pass in the arena, want to do MEMGetBaseHeapHandle(1);
 
Last edited by NWPlayer123,

VinsCool

Persona Secretiva Felineus
Global Moderator
Joined
Jan 7, 2014
Messages
14,600
Trophies
4
Location
Another World
Website
www.gbatemp.net
XP
25,217
Country
Canada
Should I turn off my wiiu internet to be on the safe side
Yes, or:

>You could use your router IRL filtering/Parental control to block updates
>Use the Tubehax DNS (forgot the adress, sorry)
 

eliboa

Well-Known Member
Member
Joined
Jan 13, 2016
Messages
157
Trophies
0
XP
1,257
Country
France
Probably not unless you use u32 MEMGetBaseHeapHandle(int arena); void* MEMAllocFromExpHeapEx(u32 *handle, u32 size, int alignment); Be sure to check if the alloc value returned is NULL.
EDIT: whoops, changed something, need to pass in the arena, want to do MEMGetBaseHeapHandle(1);
Thanks but it doesn't work...
Must be something wrong with my code :
Code:
    uint32_t coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
    uint32_t (*MEMGetBaseHeapHandle)(int mem_arena);
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMGetBaseHeapHandle", &MEMGetBaseHeapHandle);
    uint32_t *memalign, *freemem;
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMAllocFromExpHeapEx", &memalign); 
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMFreeToDefaultHeap", &freemem); 
    void* (*MEMAllocFromExpHeapEx)(uint32_t heap, uint32_t size, int align) = (void*(*)(uint32_t,uint32_t,int))*memalign;
    void  (*MEMFreeToDefaultHeap)(void *ptr) = (void (*)(void*))*freemem;

    uint32_t heap = MEMGetBaseHeapHandle(1);
    void *buffer = MEMAllocFromExpHeapEx(heap, 0x200, 0x20);
    if(buffer == NULL) OSFatal("Memory allocation failed");
    OSFatal("Buffer allocated");
    MEMFreeToDefaultHeap(buffer);
It crashes before OSFatal... no clue :unsure:
 
Last edited by eliboa,

SonyUSA

We're all mad here
Editorial Team
Joined
May 12, 2006
Messages
1,780
Trophies
2
XP
5,626
Country
United States
Thanks but it doesn't work...
Must be something wrong with my code :
Code:
    uint32_t coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
    uint32_t (*MEMGetBaseHeapHandle)(int mem_arena);
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMGetBaseHeapHandle", &MEMGetBaseHeapHandle);
    uint32_t *memalign, *freemem;
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMAllocFromExpHeapEx", &memalign);
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMFreeToDefaultHeap", &freemem);
    void* (*MEMAllocFromExpHeapEx)(uint32_t heap, uint32_t size, int align) = (void*(*)(uint32_t,uint32_t,int))*memalign;
    void  (*MEMFreeToDefaultHeap)(void *ptr) = (void (*)(void*))*freemem;

    uint32_t heap = MEMGetBaseHeapHandle(1);
    void *buffer = MEMAllocFromExpHeapEx(heap, 0x200, 0x20);
    if(buffer == NULL) OSFatal("Memory allocation failed");
    OSFatal("Buffer allocated");
    MEMFreeToDefaultHeap(buffer);
It crashes before OSFatal... no clue :unsure:

What are you trying to do?

I know I'm new, but your IF syntax looks wrong... if () {};
 
Last edited by SonyUSA,

gudenau

Largely ignored
Member
Joined
Jul 7, 2010
Messages
3,882
Trophies
2
Location
/dev/random
Website
www.gudenau.net
XP
5,402
Country
United States
The loader works great. Thanks!

--------------------- MERGED ---------------------------

Thanks but it doesn't work...
Must be something wrong with my code :
Code:
    uint32_t coreinit_handle;
    OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
    uint32_t (*MEMGetBaseHeapHandle)(int mem_arena);
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMGetBaseHeapHandle", &MEMGetBaseHeapHandle);
    uint32_t *memalign, *freemem;
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMAllocFromExpHeapEx", &memalign);
    OSDynLoad_FindExport(coreinit_handle, 0, "MEMFreeToDefaultHeap", &freemem);
    void* (*MEMAllocFromExpHeapEx)(uint32_t heap, uint32_t size, int align) = (void*(*)(uint32_t,uint32_t,int))*memalign;
    void  (*MEMFreeToDefaultHeap)(void *ptr) = (void (*)(void*))*freemem;

    uint32_t heap = MEMGetBaseHeapHandle(1);
    void *buffer = MEMAllocFromExpHeapEx(heap, 0x200, 0x20);
    if(buffer == NULL) OSFatal("Memory allocation failed");
    OSFatal("Buffer allocated");
    MEMFreeToDefaultHeap(buffer);
It crashes before OSFatal... no clue :unsure:
Keep in mind that it can never get to MEMFreeToDefaultHeap.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: Back when I was playing kakarot I looked up one little guide now all I see is dbz stuff