New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nn_fp: Implement GetMyComment and UpdateCommentAsync #1173
base: main
Are you sure you want to change the base?
Conversation
rewfs98
commented
Apr 12, 2024
- When starting a friend session, myComment (nexComment) will be stored in the session (NexFriends) variable
- Using GetMyComment will then get session->myComment and convert the commentString to UTF16
- Implemented nexComment.writeData
- UpdateCommentAsync and UpdatePreferenceAsync are incredibly similiar to each other, so most of the code is copied over from that in order to make it work
…_2nn2fpFPCwPFQ2_2nn6ResultPv_vPv
… CallHandler_GetMyComment and add CallHandler_UpdateCommentAsync
…mment, add getMyComment and updateCommentAsync functions
…NexFriends::getMyComment and NexFriends::updateCommentAsync
I'll have to convert this as a draft for now, still seems to have a few issues and I opened this PR a bit too soon. |
Something I have noticed, this does not work too well without nn_fp.rpl placed in cafeLibs/, GetMyComment doesn't get called (meaning you can't read your own comment) and UpdateCommentAsync seems to corrupt myPresence->GameKey on the client (comment still updates for other friends and the title remains untouched serverside), I'm not exactly sure on what to do about this. |
src/Cafe/OS/libs/nn_fp/nn_fp.cpp
Outdated
{ | ||
FP_API_BASE(); | ||
auto ipcCtx = std::make_unique<FPIpcContext>(iosu::fpd::FPD_REQUEST_ID::UpdateCommentAsync); | ||
ipcCtx->AddInput(newComment, 36); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newComment
is a null-terminated big-endian wide string and our current convention for those is to define them as uint16be*
But also I took a quick look into nn_fp.rpl and it behaves differently here. The length passed to AddInput
is dynamically calculated. I think this is how its implemented:
uint32 commentLen = CafeStringHelpers::Length(newComment, 17);
if(commentLen>=17)
return FPResult_InvalidIPCParam;
ipcCtx->AddInput(newComment, sizeof(uint16be) * (commentLen + 1));
So it seems to work similar to how UpdateGameModeWithUnusedParam
passes it's string.
src/Cafe/IOSU/legacy/iosu_fpd.cpp
Outdated
return FPResult_InvalidIPCParam; | ||
if (!g_fpd.nexFriendSession) | ||
return FPResult_RequestFailed; | ||
DeclareInputPtr(newComment, char16_t, (vecOut[0].size / 2), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char16_t
should be uint16be
The way this reads the string from the buffer doesn't match IOSU behavior. Take a look at CallHandler_UpdateGameMode
for the general pattern.
src/Cafe/IOSU/legacy/iosu_fpd.cpp
Outdated
DeclareInputPtr(newComment, char16_t, (vecOut[0].size / 2), 0); | ||
IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); | ||
|
||
auto utf8_comment = StringHelpers::ToUtf8((const uint16be*)newComment, vecIn[0].size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are passing the size in bytes to ToUtf8
, but it wants the size in wide characters.
There seem to be some out of bounds reads but no bad writes (unless MY_COMMENT_LENGTH is wrong or we are using it in the wrong places?) So not sure what could be causing the corruption. The call to |
Is there a clear indicator to find where that state is? |
Not much progress has been done lately, however, |
Another note, the |