Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LunaMoo/ec340ddf0f6bc7c7277e7b9603061a8e to your computer and use it in GitHub Desktop.
Save LunaMoo/ec340ddf0f6bc7c7277e7b9603061a8e to your computer and use it in GitHub Desktop.
From 199ff5d519a84565e1d98f92909105452295785d Mon Sep 17 00:00:00 2001
From: LunaMoo <moo@moo.moo>
Date: Thu, 20 Oct 2016 22:07:10 +0200
Subject: [PATCH] Completely wrong and hackish /not for merging /MGS PW recruit
---
Core/HLE/sceNet.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 83 insertions(+), 14 deletions(-)
diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp
index 002eb03..bedd6fd 100644
--- a/Core/HLE/sceNet.cpp
+++ b/Core/HLE/sceNet.cpp
@@ -271,6 +271,64 @@ static int sceNetApctlTerm() {
return 0;
}
+static int sceNetApctlScanSSID2() {
+ WARN_LOG(SCENET, "UNTESTED sceNetApctlScanSSID2()");
+ //might need to do something here, no idea what, it never has any address in arguments where it could expect something more
+ //currently a workaround is inside sceNetApctlAddHandler in form of a nasty hack, I don't like it:|
+ //might also be related to completely different function, maybe even sceNetApctlAddHandler itself
+ return 0;
+}
+
+static int sceNetApctlGetBSSDescIDList2(u32 Arg1, u32 Arg2, u32 Arg3, u32 Arg4) {
+ ERROR_LOG(SCENET, "UNIMPL sceNetApctlGetBSSDescIDList2()");
+ //honestly no idea what it's arguments are nor how many there should be;p
+ //Arg1 stores 09FBF300 which stores value 00000100
+ //Arg2 stores 09FBF3F4 which stores 0 and actually starts an empty block of 0x100 size
+ //Arg3 is 0x100
+ //Arg4 is 1
+ //potentially there are just 2 arguments, one should read the limit of the list lenght which would end as 0x100,
+ //the second would be a block to return up to 0x100 data / ID list
+ //The game expects every data saved to be an address, yet number of those are the only thing that matters
+ //so let's just return following addresses
+ if (Memory::IsValidAddress(Arg2) && Memory::IsValidAddress(Arg1)) {
+ int max_hotspots = Memory::Read_U32(Arg1) / 4;
+ int number_of_hotspots = rand() %max_hotspots;
+ WARN_LOG(SCENET, "Number of hotspots generated: %x", number_of_hotspots);
+ u32 SomeAddress;
+ for (int i = 0; i < (number_of_hotspots - 1); i++) {
+ SomeAddress = Arg2 + ((i + 1) * 4);
+ Memory::Write_U32(SomeAddress, Arg2 + (i * 4));
+ }
+ return 0;
+ } else {
+ return 0x8002013A;
+ }
+}
+
+static int sceNetApctlGetBSSDescEntry2(u32 Arg1, u32 Arg2, u32 Arg3, u32 Arg4) {
+ ERROR_LOG(SCENET, "UNIMPL sceNetApctlGetBSSDescEntry2()");
+ //This function is called multiply times and the returned data is immediately used by the game
+ //Arg1 starts as 0, but actually should be a word that returns into 09FBF3F4 in sceNetApctlGetBSSDescIDList2
+ //I think this just tells which hotspot should be checked for the rest of the data
+ //Arg2 starts as 3, then 4, 0, 1, 2 I belive this tells which description data should be returned,
+ //no idea which is what so return random values for everything, this might only work for MGS through,
+ //since it writes all data to same address and then just calculate stuff based on it
+ //longest data should be 32 bytes long ~ SSID?
+ //Arg3 is 09FBF340 where the data should be saved
+ //Arg4 starts as 1
+ if (Memory::IsValidAddress(Arg3)) {
+ u8 DescRandom;
+ for (int i = 0; i < 32; i++) {
+ DescRandom = rand();
+ WARN_LOG(SCENET, "Random stuff number %x for data %x = %x", i, Arg2, DescRandom);
+ Memory::Write_U8(DescRandom, Arg3 + i);
+ }
+ return 0;
+ } else {
+ return 0x8002013A;
+ }
+}
+
// TODO: How many handlers can the PSP actually have for Apctl?
// TODO: Should we allow the same handler to be added more than once?
static u32 sceNetApctlAddHandler(u32 handlerPtr, u32 handlerArg) {
@@ -292,6 +350,17 @@ static u32 sceNetApctlAddHandler(u32 handlerPtr, u32 handlerArg) {
}
}
+ //Nasty hack for MGS PW recruit option
+ u32 hackMGSrecruit = handlerPtr + 0x334;
+ if(Memory::IsValidAddress(hackMGSrecruit)) {
+ u32 hackMGSrecruitOp = Memory::Read_U32(hackMGSrecruit);
+ if (hackMGSrecruitOp == 0x7C0218C4) {
+ Memory::Write_U32(0x34020008, hackMGSrecruit);
+ currentMIPS->InvalidateICache(hackMGSrecruit, 4);
+ WARN_LOG(SCENET, "hackMGSrecruit replaced opcode");
+ }
+ }
+
if(!foundHandler && Memory::IsValidAddress(handlerPtr)) {
if(apctlHandlers.size() >= MAX_APCTL_HANDLERS) {
ERROR_LOG(SCENET, "UNTESTED sceNetApctlAddHandler(%x, %x): Too many handlers", handlerPtr, handlerArg);
@@ -540,20 +609,20 @@ static int sceNetSetDropRate(u32 dropRate, u32 dropDuration)
};
const HLEFunction sceNetApctl[] = {
- {0XCFB957C6, nullptr, "sceNetApctlConnect", '?', "" },
- {0X24FE91A1, &WrapI_V<sceNetApctlDisconnect>, "sceNetApctlDisconnect", 'i', "" },
- {0X5DEAC81B, nullptr, "sceNetApctlGetState", '?', "" },
- {0X8ABADD51, &WrapU_UU<sceNetApctlAddHandler>, "sceNetApctlAddHandler", 'x', "xx" },
- {0XE2F91F9B, &WrapI_V<sceNetApctlInit>, "sceNetApctlInit", 'i', "" },
- {0X5963991B, &WrapI_U<sceNetApctlDelHandler>, "sceNetApctlDelHandler", 'i', "x" },
- {0XB3EDD0EC, &WrapI_V<sceNetApctlTerm>, "sceNetApctlTerm", 'i', "" },
- {0X2BEFDF23, nullptr, "sceNetApctlGetInfo", '?', "" },
- {0XA3E77E13, nullptr, "sceNetApctlScanSSID2", '?', "" },
- {0XE9B2E5E6, nullptr, "sceNetApctlScanUser", '?', "" },
- {0XF25A5006, nullptr, "sceNetApctlGetBSSDescIDList2", '?', "" },
- {0X2935C45B, nullptr, "sceNetApctlGetBSSDescEntry2", '?', "" },
- {0X04776994, nullptr, "sceNetApctlGetBSSDescEntryUser", '?', "" },
- {0X6BDDCB8C, nullptr, "sceNetApctlGetBSSDescIDListUser", '?', "" },
+ {0XCFB957C6, nullptr, "sceNetApctlConnect", '?', "" },
+ {0X24FE91A1, &WrapI_V<sceNetApctlDisconnect>, "sceNetApctlDisconnect", 'i', "" },
+ {0X5DEAC81B, nullptr, "sceNetApctlGetState", '?', "" },
+ {0X8ABADD51, &WrapU_UU<sceNetApctlAddHandler>, "sceNetApctlAddHandler", 'x', "xx" },
+ {0XE2F91F9B, &WrapI_V<sceNetApctlInit>, "sceNetApctlInit", 'i', "" },
+ {0X5963991B, &WrapI_U<sceNetApctlDelHandler>, "sceNetApctlDelHandler", 'i', "x" },
+ {0XB3EDD0EC, &WrapI_V<sceNetApctlTerm>, "sceNetApctlTerm", 'i', "" },
+ {0X2BEFDF23, nullptr, "sceNetApctlGetInfo", '?', "" },
+ {0XA3E77E13, &WrapI_V<sceNetApctlScanSSID2>, "sceNetApctlScanSSID2", 'i', "" },
+ {0XE9B2E5E6, nullptr, "sceNetApctlScanUser", '?', "" },
+ {0XF25A5006, &WrapI_UUUU<sceNetApctlGetBSSDescIDList2>, "sceNetApctlGetBSSDescIDList2", 'i', "xxxx" },
+ {0X2935C45B, &WrapI_UUUU<sceNetApctlGetBSSDescEntry2>, "sceNetApctlGetBSSDescEntry2", 'i', "xxxx" },
+ {0X04776994, nullptr, "sceNetApctlGetBSSDescEntryUser", '?', "" },
+ {0X6BDDCB8C, nullptr, "sceNetApctlGetBSSDescIDListUser", '?', "" },
};
const HLEFunction sceWlanDrv[] = {
--
1.9.5.msysgit.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment