MCPcopy Create free account
hub / github.com/devkitPro/libctru / udsInit

Function udsInit

libctru/source/services/uds.c:47–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45static Result usd_parsebeacon(u8 *buf, u32 size, udsNetworkScanInfo *networkscan);
46
47Result udsInit(size_t sharedmem_size, const char *username)
48{
49 Result ret=0;
50 u32 ndm_state = 0;
51
52 if (AtomicPostIncrement(&__uds_refcount)) return 0;
53
54 ret = ndmuInit();
55 if(R_SUCCEEDED(ret))
56 {
57 ndm_state = 1;
58 ret = NDMU_EnterExclusiveState(NDM_EXCLUSIVE_STATE_LOCAL_COMMUNICATIONS);
59 if(R_SUCCEEDED(ret))
60 {
61 ndm_state = 2;
62 }
63 }
64
65 if(R_SUCCEEDED(ret))
66 {
67 ret = srvGetServiceHandle(&__uds_servhandle, "nwm::UDS");
68 if(R_SUCCEEDED(ret))
69 {
70 ret = uds_Initialize(sharedmem_size, username);
71 if (R_FAILED(ret))
72 {
73 svcCloseHandle(__uds_servhandle);
74 __uds_servhandle = 0;
75 }
76 }
77 }
78
79 if (R_FAILED(ret))
80 {
81 if(ndm_state)
82 {
83 if(ndm_state==2)NDMU_LeaveExclusiveState();
84 ndmuExit();
85 }
86
87 AtomicDecrement(&__uds_refcount);
88 }
89
90 bind_allocbitmask = 0;
91
92 return ret;
93}
94
95void udsExit(void)
96{

Callers

nothing calls this directly

Calls 6

ndmuInitFunction · 0.85
NDMU_EnterExclusiveStateFunction · 0.85
srvGetServiceHandleFunction · 0.85
uds_InitializeFunction · 0.85
NDMU_LeaveExclusiveStateFunction · 0.85
ndmuExitFunction · 0.85

Tested by

no test coverage detected