switchbrew / libnx

Library for Switch Homebrew
https://switchbrew.github.io/libnx/
ISC License
1.26k stars 167 forks source link

hiddbg: modify hiddbgAttachHdlsWorkBuffer to accept a user-supplied buffer and size #601

Closed ndeadly closed 1 year ago

ndeadly commented 1 year ago

The current version of hiddbgAttachHdlsWorkBuffer is incompatible with sysmodules using libstratosphere due to the libnx memory allocations in tmemCreate. This modifies the existing function to create a transfer memory from an optional user-supplied buffer using tmemCreateFromMemory instead.

I wasn't sure whether breaking the existing API by adding the additional parameters was a good idea, but this seems like the most straightforward solution.

fincs commented 1 year ago

Given that this command makes most sense to use in sysmodules (and I believe you are the only user), I think you can remove the old tmemCreate handling; leaving explicit memory management as the only option.

ndeadly commented 1 year ago

There are definitely a few others using it who may be affected (sys-con and sys-botbase come to mind). I have no problem with removing the old handling though. Up to you guys.