summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/service.cpp4
-rw-r--r--src/core/hle/service/service.h4
-rw-r--r--src/core/loader/ncch.cpp12
-rw-r--r--src/core/loader/ncch.h8
4 files changed, 13 insertions, 15 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index d3af2768a..00ac1c9c6 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -41,7 +41,7 @@ void Manager::AddService(Interface* service) {
41} 41}
42 42
43/// Removes a service from the manager, also frees memory 43/// Removes a service from the manager, also frees memory
44void Manager::DeleteService(std::string port_name) { 44void Manager::DeleteService(const std::string& port_name) {
45 Interface* service = FetchFromPortName(port_name); 45 Interface* service = FetchFromPortName(port_name);
46 m_services.erase(std::remove(m_services.begin(), m_services.end(), service), m_services.end()); 46 m_services.erase(std::remove(m_services.begin(), m_services.end(), service), m_services.end());
47 m_port_map.erase(port_name); 47 m_port_map.erase(port_name);
@@ -54,7 +54,7 @@ Interface* Manager::FetchFromHandle(Handle handle) {
54} 54}
55 55
56/// Get a Service Interface from its port 56/// Get a Service Interface from its port
57Interface* Manager::FetchFromPortName(std::string port_name) { 57Interface* Manager::FetchFromPortName(const std::string& port_name) {
58 auto itr = m_port_map.find(port_name); 58 auto itr = m_port_map.find(port_name);
59 if (itr == m_port_map.end()) { 59 if (itr == m_port_map.end()) {
60 return nullptr; 60 return nullptr;
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index cb1ecde31..c0e803bda 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -149,13 +149,13 @@ public:
149 void AddService(Interface* service); 149 void AddService(Interface* service);
150 150
151 /// Removes a service from the manager (does not delete it though) 151 /// Removes a service from the manager (does not delete it though)
152 void DeleteService(std::string port_name); 152 void DeleteService(const std::string& port_name);
153 153
154 /// Get a Service Interface from its UID 154 /// Get a Service Interface from its UID
155 Interface* FetchFromHandle(u32 uid); 155 Interface* FetchFromHandle(u32 uid);
156 156
157 /// Get a Service Interface from its port 157 /// Get a Service Interface from its port
158 Interface* FetchFromPortName(std::string port_name); 158 Interface* FetchFromPortName(const std::string& port_name);
159 159
160private: 160private:
161 161
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index ba27eb75a..9af59e419 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -40,19 +40,17 @@ u32 LZSS_GetDecompressedSize(u8* buffer, u32 size) {
40bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32 decompressed_size) { 40bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32 decompressed_size) {
41 u8* footer = compressed + compressed_size - 8; 41 u8* footer = compressed + compressed_size - 8;
42 u32 buffer_top_and_bottom = *(u32*)footer; 42 u32 buffer_top_and_bottom = *(u32*)footer;
43 u32 i, j;
44 u32 out = decompressed_size; 43 u32 out = decompressed_size;
45 u32 index = compressed_size - ((buffer_top_and_bottom >> 24) & 0xFF); 44 u32 index = compressed_size - ((buffer_top_and_bottom >> 24) & 0xFF);
46 u8 control;
47 u32 stop_index = compressed_size - (buffer_top_and_bottom & 0xFFFFFF); 45 u32 stop_index = compressed_size - (buffer_top_and_bottom & 0xFFFFFF);
48 46
49 memset(decompressed, 0, decompressed_size); 47 memset(decompressed, 0, decompressed_size);
50 memcpy(decompressed, compressed, compressed_size); 48 memcpy(decompressed, compressed, compressed_size);
51 49
52 while(index > stop_index) { 50 while(index > stop_index) {
53 control = compressed[--index]; 51 u8 control = compressed[--index];
54 52
55 for(i = 0; i < 8; i++) { 53 for(u32 i = 0; i < 8; i++) {
56 if(index <= stop_index) 54 if(index <= stop_index)
57 break; 55 break;
58 if(index <= 0) 56 if(index <= 0)
@@ -76,13 +74,13 @@ bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32
76 if(out < segment_size) { 74 if(out < segment_size) {
77 return false; 75 return false;
78 } 76 }
79 for(j = 0; j < segment_size; j++) { 77 for(u32 j = 0; j < segment_size; j++) {
80 u8 data;
81 // Check if compression is out of bounds 78 // Check if compression is out of bounds
82 if(out + segment_offset >= decompressed_size) { 79 if(out + segment_offset >= decompressed_size) {
83 return false; 80 return false;
84 } 81 }
85 data = decompressed[out + segment_offset]; 82
83 u8 data = decompressed[out + segment_offset];
86 decompressed[--out] = data; 84 decompressed[--out] = data;
87 } 85 }
88 } else { 86 } else {
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 29b59aa11..f40a258b7 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -46,17 +46,17 @@ struct NCCH_Header {
46//////////////////////////////////////////////////////////////////////////////////////////////////// 46////////////////////////////////////////////////////////////////////////////////////////////////////
47// ExeFS (executable file system) headers 47// ExeFS (executable file system) headers
48 48
49typedef struct { 49struct ExeFs_SectionHeader {
50 char name[8]; 50 char name[8];
51 u32 offset; 51 u32 offset;
52 u32 size; 52 u32 size;
53} ExeFs_SectionHeader; 53};
54 54
55typedef struct { 55struct ExeFs_Header {
56 ExeFs_SectionHeader section[8]; 56 ExeFs_SectionHeader section[8];
57 u8 reserved[0x80]; 57 u8 reserved[0x80];
58 u8 hashes[8][0x20]; 58 u8 hashes[8][0x20];
59} ExeFs_Header; 59};
60 60
61//////////////////////////////////////////////////////////////////////////////////////////////////// 61////////////////////////////////////////////////////////////////////////////////////////////////////
62// ExHeader (executable file system header) headers 62// ExHeader (executable file system header) headers