Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Update v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
KcrPL committed Aug 2, 2020
1 parent 8a724d6 commit 3a858cf
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 16 deletions.
21 changes: 16 additions & 5 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ int main(int argc, char** argv) {
VIDEO_WaitVSync();
if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();

printf("\n:------------------------------------------------:\n");
printf(": RiiConnect24 Mail Patcher - (C) Spotlight v1.2 :\n: Compiled on 2020/08/02 at 7:14PM :\n");
printf(":------------------------------------------------:\n");

printf("Connecting to the Internet... OK\n");
// The console understands VT terminal escape codes
// This positions the cursor on row 2, column 0
// we can use variables for this with format codes too
Expand Down Expand Up @@ -155,7 +160,7 @@ int main(int argc, char** argv) {
// for (int i = 0; i < sizeof(tst); i++)
// printf("%.2x", tst[i]);

printf("\n\nRunning...\n\n\n\n\n");
printf("\nPatching...\n\n");

s32 systemVersion = getSystemMenuVersion();

Expand All @@ -167,14 +172,20 @@ int main(int argc, char** argv) {
printf("RiiConnect24 works best on 4.3 (if you update, please repatch!)\nThe "
"installer will continue.\n");
}

s64 friendCode = getFriendCode();
s32 error = patchMail();
if (error == RESPONSE_AREGISTERED) {
printf("If your previous registration failed, please\ncontact a developer at [email protected].\n");
printf("\nIf your previous registration failed, please contact us using:\n- Discord: https://discord.gg/b4Y7jfD\n Wait time: Short, send a Direct Message to a developer.\n- E-Mail: [email protected]\n Wait time: up to 24 hours, sometimes longer\n");
printf("\nIf you're repatching, contact us and provide this info:\n");
printf("\nYour friend code: w");
printf("%016llu\n", friendCode);
} else if (error != 0) {
printf("An error occurred! Please send a screenshot of this error message\nto a developer or at [email protected].\n");
printf("There was an error while patching.\nPlease make a screenshot of this error message and send it\nto a developer.\n");
printf("\nContact using:\n- Discord: https://discord.gg/b4Y7jfD\n Wait time: Short, send a Direct Message to a developer.\n- E-Mail: [email protected]\n Wait time: up to 24 hours, sometimes longer\n");
printf("\nYour friend code: w");
printf("%016llu\n", friendCode);
} else {
printf("Finished!\nPress HOME to exit.\n");
printf("All done, all done!\nPress HOME to exit.\n");
}
}

Expand Down
52 changes: 41 additions & 11 deletions source/patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ s32 patchMail() {

s32 error = NAND_ReadFile("/shared2/wc24/nwc24msg.cfg", fileBufferNWC24MSG, 0x400);
if (error < 0) {
printf("The nwc24msg.cfg file couldn't be read\n");
printf(":-----------------------------------------:\n");
printf(": The nwc24msg.cfg file couldn't be read. :\n");
printf(":-----------------------------------------:\n\n");
return error;
}
memcpy(&fileUnionNWC24MSG, fileBufferNWC24MSG, 0x400);
Expand All @@ -129,23 +131,43 @@ s32 patchMail() {
return -1;
}
if (oldChecksum != calculatedChecksum) {
printf("The checksum isn't corresponding\n");
printf(":-----------------------------------------:\n");
printf(": The checksum isn't corresponding. :\n");
printf(":-----------------------------------------:\n\n");
return -1;
}

// Get the friend code
s64 fc = fileUnionNWC24MSG.structNWC24MSG.friendCode;
if (fc < 0) {
printf("Invalid Friend Code: %lli\n", fc);
printf(":-----------------------------------------:\n");
printf(" Invalid Friend Code: %lli\n", fc);
printf(":-----------------------------------------:\n\n");
return fc;
}

// Request for a passwd/mlchkid
char response[2048] = "";
sprintf(response, "mlid=w%016lli", fc);
error = postRequest(BASE_HTTP_URL, "/cgi-bin/patcher.cgi", 80, &response, sizeof(response));
if (error < 0) {
printf("Couldn't request the data: %li\n", error);

//
if (error == -24) {
printf(":--------------------------------------------------------:");
printf("\n: There is no Internet connection. :");
printf("\n: Please check if your Wii is connected to the Internet. :");
printf("\n: :");
printf("\n: Could not reach remote host. :");
printf("\n:--------------------------------------------------------:\n\n");

}
if (error < 0) {
return error;
}
if (error < 0 && error != -24) {
printf(":-----------------------------------------:\n");
printf(" Couldn't request the data: %li\n", error);
printf(":-----------------------------------------:\n\n");
return error;
}

Expand Down Expand Up @@ -179,15 +201,21 @@ s32 patchMail() {
// Check the response code
switch (responseCode) {
case RESPONSE_INVALID:
printf("Invalid friend code\n");
printf(":-----------------------------------------:\n");
printf(": Invalid friend code. :\n");
printf(":-----------------------------------------:\n");
return 1;
break;
case RESPONSE_AREGISTERED:
printf("Already registered\n");
printf(":----------------------------------------------------:\n");
printf(": Your Wii's Friend Code is already in our database. :\n");
printf(":----------------------------------------------------:\n");
return RESPONSE_AREGISTERED;
break;
case RESPONSE_DB_ERROR:
printf("Server database error.");
printf(":-----------------------------------------:\n");
printf(": Server database error. Try again later. :\n");
printf(":-----------------------------------------:\n");
return 1;
break;
case RESPONSE_OK:
Expand All @@ -196,13 +224,15 @@ s32 patchMail() {
return 1;
} else {
// Patch the nwc24msg.cfg file
printf("before:%s\n", fileUnionNWC24MSG.structNWC24MSG.mailDomain);
printf("Domain before: %s\n", fileUnionNWC24MSG.structNWC24MSG.mailDomain);
patchNWC24MSG(&fileUnionNWC24MSG, responsePasswd, responseMlchkid);
printf("after:%s\n", fileUnionNWC24MSG.structNWC24MSG.mailDomain);
printf("Domain after: %s\n\n", fileUnionNWC24MSG.structNWC24MSG.mailDomain);

error = NAND_WriteFile("/shared2/wc24/nwc24msg.cfg", fileUnionNWC24MSG.charNWC24MSG, 0x400, false);
if (error < 0) {
printf("The nwc24msg.cfg file couldn't be updated.\n");
printf(":--------------------------------------------:\n");
printf(": The nwc24msg.cfg file couldn't be updated. :\n");
printf(":--------------------------------------------:\n\n");
return error;
}
return 0;
Expand Down

0 comments on commit 3a858cf

Please sign in to comment.