Skip to content

Commit

Permalink
make ldnmitm_config working on ReiNX
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemeowx2 committed Dec 28, 2018
1 parent 434af8c commit ec51fc0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 45 deletions.
3 changes: 2 additions & 1 deletion ldn_mitm/ldn_mitm.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"svcGetDebugThreadContext": "0x67",
"svcQueryDebugProcessMemory": "0x69",
"svcReadDebugProcessMemory": "0x6a",
"svcGetDebugThreadParam": "0x6d"
"svcGetDebugThreadParam": "0x6d",
"svcManageNamedPort": "0x71"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion ldn_mitm/source/ldnmitm_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int main(int argc, char **argv)

/* Create ldn:u mitm. */
AddMitmServerToManager<LdnMitMService>(server_manager, "ldn:u", 1);
server_manager->AddWaitable(new ServiceServer<LdnConfig>("ldnmitm", 1));
server_manager->AddWaitable(new ManagedPortServer<LdnConfig>("ldnmitm:cfg", 1));

/* Loop forever, servicing our services. */
server_manager->Process();
Expand Down
2 changes: 1 addition & 1 deletion ldnmitm_config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules

GITREV := $(shell git rev-parse HEAD 2>/dev/null | cut -c1-8)
VERSION := v1.0.0
VERSION := v1.1.0
ifneq ($(strip $(GITREV)),)
VERSION := $(VERSION)-$(GITREV)
endif
Expand Down
37 changes: 4 additions & 33 deletions ldnmitm_config/source/ldn.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,39 +211,10 @@ Result ldnCreateUserLocalCommunicationService(Service* s, UserLocalCommunication
return rc;
}

Result ldnMitmGetConfig(Service* s, LdnMitmConfigService *out) {
IpcCommand c;
ipcInitialize(&c);

struct {
u64 magic;
u64 cmd_id;
} *raw;

raw = serviceIpcPrepareHeader(s, &c, sizeof(*raw));

raw->magic = SFCI_MAGIC;
raw->cmd_id = 65000;

Result rc = serviceIpcDispatch(s);

if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;

serviceIpcParse(s, &r, sizeof(*resp));
resp = r.Raw;

rc = resp->result;

if (R_SUCCEEDED(rc)) {
serviceCreateSubservice(&out->s, s, &r, 0);
}
}

Result ldnMitmGetConfig(LdnMitmConfigService *out) {
Handle handle;
Result rc = svcConnectToNamedPort(&handle, "ldnmitm:cfg");
serviceCreate(&out->s, handle);
return rc;
}

Expand Down
2 changes: 1 addition & 1 deletion ldnmitm_config/source/ldn.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Result ldnMitmGetLogging(LdnMitmConfigService *s, u32 *enabled);
Result ldnMitmSetLogging(LdnMitmConfigService *s, u32 enabled);
Result ldnMitmGetEnabled(LdnMitmConfigService *s, u32 *enabled);
Result ldnMitmSetEnabled(LdnMitmConfigService *s, u32 enabled);
Result ldnMitmGetConfig(Service* s, LdnMitmConfigService *out);
Result ldnMitmGetConfig(LdnMitmConfigService *out);
void NetworkInfo2NetworkConfig(NetworkInfo* info, NetworkConfig* out);
void NetworkInfo2SecurityParameter(NetworkInfo* info, SecurityParameter* out);

Expand Down
11 changes: 3 additions & 8 deletions ldnmitm_config/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "test.h"

#define MODULEID 0x233
static Service g_ldnSrv;
static LdnMitmConfigService g_ldnConfig;

Result saveLogToFile() {
Expand All @@ -21,7 +20,6 @@ Result saveLogToFile() {
}

void cleanup() {
serviceClose(&g_ldnSrv);
serviceClose(&g_ldnConfig.s);
}

Expand Down Expand Up @@ -115,13 +113,10 @@ int main() {
gfxInitDefault();
consoleInit(NULL);

Result rc = smGetService(&g_ldnSrv, "ldn:u");
Result rc = ldnMitmGetConfig(&g_ldnConfig);
if (R_FAILED(rc)) {
die("failed to get service ldn:u");
}
rc = ldnMitmGetConfig(&g_ldnSrv, &g_ldnConfig);
if (R_FAILED(rc)) {
die("ldn_mitm is not loaded or too old(requires ldn_mitm > v1.0)");
printf("error code: %x\n", rc);
die("ldn_mitm is not loaded or too old(requires ldn_mitm >= v1.1.1)");
}

reprint();
Expand Down

0 comments on commit ec51fc0

Please sign in to comment.