Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap
Commits
52668e33
Commit
52668e33
authored
5 years ago
by
Constantin Papizh
Browse files
Options
Downloads
Patches
Plain Diff
Win registry functionality
parent
fbf797eb
No related branches found
No related tags found
1 merge request
!12
bug 2539
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/dap_common.h
+4
-0
4 additions, 0 deletions
include/dap_common.h
src/win32/registry.c
+118
-0
118 additions, 0 deletions
src/win32/registry.c
src/win32/registry.h
+15
-0
15 additions, 0 deletions
src/win32/registry.h
src/win32/win32.pri
+4
-2
4 additions, 2 deletions
src/win32/win32.pri
with
141 additions
and
2 deletions
include/dap_common.h
+
4
−
0
View file @
52668e33
...
...
@@ -90,6 +90,10 @@
#define DAP_DUP(a) ( __typeof(a) ret = memcpy(ret,a,sizeof(*a)) )
#endif
#ifndef MAX_PATH
#define MAX_PATH 120
#endif
DAP_STATIC_INLINE
void
*
_dap_aligned_alloc
(
uintptr_t
alignment
,
uintptr_t
size
)
{
uintptr_t
ptr
=
(
uintptr_t
)
DAP_MALLOC
(
size
+
(
alignment
*
2
)
+
sizeof
(
void
*
)
);
...
...
This diff is collapsed.
Click to expand it.
src/win32/registry.c
0 → 100644
+
118
−
0
View file @
52668e33
#include
"registry.h"
wchar_t
*
readRegKey
(
HKEY
hKey
,
LPCWSTR
regSubKey
,
LPCWSTR
val
)
{
wchar_t
*
wret
=
(
wchar_t
*
)
malloc
(
MAX_PATH
);
DWORD
dwSize
=
MAX_PATH
;
LSTATUS
err
=
RegGetValueW
(
hKey
,
regSubKey
,
val
,
RRF_RT_REG_SZ
,
NULL
,
(
void
*
)
wret
,
&
dwSize
);
if
(
err
==
ERROR_SUCCESS
)
{
return
wret
;
}
else
{
free
(
wret
);
return
NULL
;
}
}
char
*
regGetUsrPath
()
{
static
char
path
[
MAX_PATH
]
=
{};
if
(
strlen
(
path
)
>
3
)
{
return
path
;
}
HKEY
hKey
;
const
char
keyPath
[]
=
"SOFTWARE
\\
Microsoft
\\
Windows
\\
CurrentVersion
\\
Explorer
\\
Shell Folders"
;
LSTATUS
err
=
RegOpenKeyExA
(
HKEY_CURRENT_USER
,
keyPath
,
0
,
KEY_READ
,
&
hKey
);
if
(
err
!=
ERROR_SUCCESS
)
{
return
NULL
;
}
DWORD
len
=
MAX_PATH
;
err
=
RegGetValueA
(
hKey
,
NULL
,
"Personal"
,
RRF_RT_REG_SZ
,
NULL
,
(
void
*
)
path
,
&
len
);
RegCloseKey
(
hKey
);
return
path
;
}
wchar_t
*
getTapGUID
()
{
static
wchar_t
guid
[
MAX_PATH
]
=
{};
if
(
wcslen
(
guid
)
>
2
)
{
return
guid
;
}
const
wchar_t
keyPath
[]
=
L"SYSTEM
\\
CurrentControlSet
\\
Control
\\
Class
\\
{4D36E972-E325-11CE-BFC1-08002BE10318}"
;
HKEY
baseKey
;
LSTATUS
err
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
keyPath
,
0
,
KEY_ENUMERATE_SUB_KEYS
|
KEY_WOW64_64KEY
|
KEY_READ
,
&
baseKey
);
if
(
err
!=
ERROR_SUCCESS
)
{
return
NULL
;
}
DWORD
index
;
for
(
index
=
0
;
;
++
index
)
{
wchar_t
hKey
[
MAX_PATH
];
DWORD
len
=
MAX_PATH
;
if
(
RegEnumKeyExW
(
baseKey
,
index
,
hKey
,
&
len
,
NULL
,
NULL
,
NULL
,
NULL
)
!=
ERROR_SUCCESS
)
{
break
;
}
wchar_t
*
tmp
=
readRegKey
(
baseKey
,
hKey
,
L"ComponentId"
);
if
(
tmp
&&
wcscmp
(
tmp
,
L"tap0901"
)
==
0
)
{
wchar_t
*
tmp2
=
readRegKey
(
baseKey
,
hKey
,
L"NetCfgInstanceId"
);
wcscpy
(
guid
,
tmp2
);
free
(
tmp
);
free
(
tmp2
);
return
guid
;
}
if
(
tmp
)
free
(
tmp
);
}
return
NULL
;
}
wchar_t
*
getTapName
()
{
static
wchar_t
name
[
MAX_PATH
]
=
{};
if
(
wcslen
(
name
)
>
2
)
return
name
;
wchar_t
*
guid
=
getTapGUID
();
if
(
guid
==
NULL
)
return
NULL
;
wchar_t
keyPath
[
MAX_PATH
]
=
L"SYSTEM
\\
CurrentControlSet
\\
Control
\\
Network
\\
{4D36E972-E325-11CE-BFC1-08002BE10318}"
;
wcscat
(
keyPath
,
L"
\\
"
);
wcscat
(
keyPath
,
guid
);
HKEY
baseKey
;
LSTATUS
err
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
keyPath
,
0
,
KEY_ENUMERATE_SUB_KEYS
|
KEY_WOW64_64KEY
|
KEY_READ
,
&
baseKey
);
if
(
err
!=
ERROR_SUCCESS
)
{
return
NULL
;
}
DWORD
index
;
for
(
index
=
0
;
;
++
index
)
{
wchar_t
hKey
[
MAX_PATH
];
DWORD
len
=
MAX_PATH
;
if
(
RegEnumKeyExW
(
baseKey
,
index
,
hKey
,
&
len
,
NULL
,
NULL
,
NULL
,
NULL
)
!=
ERROR_SUCCESS
)
{
break
;
}
wchar_t
*
tmp
=
readRegKey
(
baseKey
,
hKey
,
L"Name"
);
if
(
tmp
)
{
wcscpy
(
name
,
tmp
);
free
(
tmp
);
return
name
;
}
}
return
NULL
;
}
wchar_t
*
getUserSID
(
LPCWSTR
homePath
)
{
static
wchar_t
sid
[
MAX_PATH
]
=
{};
if
(
wcslen
(
sid
)
>
2
)
return
sid
;
const
wchar_t
keyPath
[]
=
L"SOFTWARE
\\
Microsoft
\\
Windows NT
\\
CurrentVersion
\\
ProfileList"
;
HKEY
baseKey
;
LSTATUS
err
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
keyPath
,
0
,
KEY_ENUMERATE_SUB_KEYS
|
KEY_WOW64_64KEY
|
KEY_READ
,
&
baseKey
);
if
(
err
!=
ERROR_SUCCESS
)
{
return
NULL
;
}
DWORD
index
;
for
(
index
=
0
;
;
++
index
)
{
wchar_t
hKey
[
MAX_PATH
];
DWORD
len
=
MAX_PATH
;
if
(
RegEnumKeyExW
(
baseKey
,
index
,
hKey
,
&
len
,
NULL
,
NULL
,
NULL
,
NULL
)
!=
ERROR_SUCCESS
)
{
break
;
}
wchar_t
*
tmp
=
readRegKey
(
baseKey
,
hKey
,
L"ProfileImagePath"
);
if
(
tmp
&&
wcscmp
(
tmp
,
homePath
)
==
0
)
{
wcscpy
(
sid
,
hKey
);
free
(
tmp
);
return
sid
;
}
if
(
tmp
)
free
(
tmp
);
}
return
NULL
;
}
This diff is collapsed.
Click to expand it.
src/win32/registry.h
0 → 100644
+
15
−
0
View file @
52668e33
#ifndef REGISTRY_H
#define REGISTRY_H
#include
<stdio.h>
#include
<windows.h>
#include
<tchar.h>
wchar_t
*
readRegKey
(
HKEY
hKey
,
LPCWSTR
regSubKey
,
LPCWSTR
val
);
wchar_t
*
getTapGUID
();
wchar_t
*
getTapName
();
wchar_t
*
getUserSID
(
LPCWSTR
homePath
);
char
*
regGetUsrPath
();
#endif
This diff is collapsed.
Click to expand it.
src/win32/win32.pri
+
4
−
2
View file @
52668e33
HEADERS += $$PWD/dap_console_manager.h \
$$PWD/dap_cpu_monitor.h \
$$PWD/dap_process_manager.h \
$$PWD/dap_process_memory.h
$$PWD/dap_process_memory.h \
$$PWD/registry.h
SOURCES += $$PWD/dap_console_manager.c \
$$PWD/dap_cpu_monitor.c \
$$PWD/dap_process_manager.c \
$$PWD/dap_process_memory.c
$$PWD/dap_process_memory.c \
$$PWD/registry.c
INCLUDEPATH += $$PWD
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