Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
19c5cf9c
There was an error fetching the commit references. Please try again later.
Commit
19c5cf9c
authored
6 years ago
by
Zach Hilman
Browse files
Options
Downloads
Patches
Plain Diff
acc: Load user images from config dir
parent
466960c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/hle/service/acc/acc.cpp
+45
-9
45 additions, 9 deletions
src/core/hle/service/acc/acc.cpp
with
45 additions
and
9 deletions
src/core/hle/service/acc/acc.cpp
+
45
−
9
View file @
19c5cf9c
...
...
@@ -3,8 +3,11 @@
// Refer to the license.txt file included.
#include
<array>
#include
"common/common_paths.h"
#include
"common/common_types.h"
#include
"common/file_util.h"
#include
"common/logging/log.h"
#include
"common/string_util.h"
#include
"common/swap.h"
#include
"core/core_timing.h"
#include
"core/hle/ipc_helpers.h"
...
...
@@ -16,6 +19,9 @@
#include
"core/hle/service/acc/profile_manager.h"
namespace
Service
::
Account
{
constexpr
u32
MAX_JPEG_IMAGE_SIZE
=
0x20000
;
// TODO: RE this structure
struct
UserData
{
INSERT_PADDING_WORDS
(
1
);
...
...
@@ -27,6 +33,11 @@ struct UserData {
};
static_assert
(
sizeof
(
UserData
)
==
0x80
,
"UserData structure has incorrect size"
);
static
std
::
string
GetImagePath
(
const
std
::
string
&
username
)
{
return
FileUtil
::
GetUserPath
(
FileUtil
::
UserPath
::
ConfigDir
)
+
"users"
+
DIR_SEP
+
username
+
".jpg"
;
}
class
IProfile
final
:
public
ServiceFramework
<
IProfile
>
{
public:
explicit
IProfile
(
UUID
user_id
,
ProfileManager
&
profile_manager
)
...
...
@@ -38,6 +49,15 @@ public:
{
11
,
&
IProfile
::
LoadImage
,
"LoadImage"
},
};
RegisterHandlers
(
functions
);
ProfileBase
profile_base
{};
if
(
profile_manager
.
GetProfileBase
(
user_id
,
profile_base
))
{
image
=
std
::
make_unique
<
FileUtil
::
IOFile
>
(
GetImagePath
(
Common
::
StringFromFixedZeroTerminatedBuffer
(
reinterpret_cast
<
const
char
*>
(
profile_base
.
username
.
data
()),
profile_base
.
username
.
size
())),
"rb"
);
}
}
private
:
...
...
@@ -73,11 +93,11 @@ private:
}
void
LoadImage
(
Kernel
::
HLERequestContext
&
ctx
)
{
LOG_
WARNIN
G
(
Service_ACC
,
"
(STUBBED)
called"
);
LOG_
DEBU
G
(
Service_ACC
,
"called"
);
// smallest jpeg https://github.com/mathiasbynens/small/blob/master/jpeg.jpg
//
TODO(mailwl): load actual profile image from disk, width 256px, max size 0x20000
constexpr
u32
jpeg_size
=
107
;
static
constexpr
std
::
array
<
u8
,
jpeg_size
>
jpeg
{
//
used as a backup should the one on disk not exist
constexpr
u32
backup_
jpeg_size
=
107
;
static
constexpr
std
::
array
<
u8
,
backup_
jpeg_size
>
backup_
jpeg
{
0xff
,
0xd8
,
0xff
,
0xdb
,
0x00
,
0x43
,
0x00
,
0x03
,
0x02
,
0x02
,
0x02
,
0x02
,
0x02
,
0x03
,
0x02
,
0x02
,
0x02
,
0x03
,
0x03
,
0x03
,
0x03
,
0x04
,
0x06
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x08
,
0x06
,
0x06
,
0x05
,
0x06
,
0x09
,
0x08
,
0x0a
,
0x0a
,
0x09
,
0x08
,
0x09
,
0x09
,
0x0a
,
...
...
@@ -87,22 +107,38 @@ private:
0xff
,
0xcc
,
0x00
,
0x06
,
0x00
,
0x10
,
0x10
,
0x05
,
0xff
,
0xda
,
0x00
,
0x08
,
0x01
,
0x01
,
0x00
,
0x00
,
0x3f
,
0x00
,
0xd2
,
0xcf
,
0x20
,
0xff
,
0xd9
,
};
ctx
.
WriteBuffer
(
jpeg
);
IPC
::
ResponseBuilder
rb
{
ctx
,
3
};
rb
.
Push
(
RESULT_SUCCESS
);
rb
.
Push
<
u32
>
(
jpeg_size
);
if
(
image
==
nullptr
)
{
ctx
.
WriteBuffer
(
backup_jpeg
);
rb
.
Push
<
u32
>
(
backup_jpeg_size
);
}
else
{
const
auto
size
=
std
::
min
<
u32
>
(
image
->
GetSize
(),
MAX_JPEG_IMAGE_SIZE
);
std
::
vector
<
u8
>
buffer
(
size
);
image
->
ReadBytes
(
buffer
.
data
(),
buffer
.
size
());
ctx
.
WriteBuffer
(
buffer
.
data
(),
buffer
.
size
());
rb
.
Push
<
u32
>
(
buffer
.
size
());
}
}
void
GetImageSize
(
Kernel
::
HLERequestContext
&
ctx
)
{
LOG_
WARNIN
G
(
Service_ACC
,
"
(STUBBED)
called"
);
constexpr
u32
jpeg_size
=
107
;
LOG_
DEBU
G
(
Service_ACC
,
"called"
);
constexpr
u32
backup_
jpeg_size
=
107
;
IPC
::
ResponseBuilder
rb
{
ctx
,
3
};
rb
.
Push
(
RESULT_SUCCESS
);
rb
.
Push
<
u32
>
(
jpeg_size
);
if
(
image
==
nullptr
)
rb
.
Push
<
u32
>
(
backup_jpeg_size
);
else
rb
.
Push
<
u32
>
(
std
::
min
<
u32
>
(
image
->
GetSize
(),
MAX_JPEG_IMAGE_SIZE
));
}
const
ProfileManager
&
profile_manager
;
UUID
user_id
;
///< The user id this profile refers to.
std
::
unique_ptr
<
FileUtil
::
IOFile
>
image
=
nullptr
;
};
class
IManagerForApplication
final
:
public
ServiceFramework
<
IManagerForApplication
>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment