Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
m417z
kdlibcpp
Commits
ba80c2ca
Commit
ba80c2ca
authored
Nov 27, 2019
by
Mikhail I. Izmestev
Browse files
Add test cases for getRegRealativeId for CV_ALLREG_VFRAME
parent
a02b6bf3
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
195 additions
and
0 deletions
+195
-0
kdlib/tests/dumps/targetapp_test_cv_allreg_amd64/targetapp.pdb
.../tests/dumps/targetapp_test_cv_allreg_amd64/targetapp.pdb
+0
-0
kdlib/tests/dumps/targetapp_test_cv_allreg_amd64/targetapp_test_cv_allreg_amd64.cab
...p_test_cv_allreg_amd64/targetapp_test_cv_allreg_amd64.cab
+0
-0
kdlib/tests/dumps/targetapp_test_cv_allreg_i386/targetapp.pdb
...b/tests/dumps/targetapp_test_cv_allreg_i386/targetapp.pdb
+0
-0
kdlib/tests/dumps/targetapp_test_cv_allreg_i386/targetapp_test_cv_allreg_i386.cab
...app_test_cv_allreg_i386/targetapp_test_cv_allreg_i386.cab
+0
-0
kdlib/tests/kdlibtest/memdumpfixture.h
kdlib/tests/kdlibtest/memdumpfixture.h
+2
-0
kdlib/tests/kdlibtest/stacktest.cpp
kdlib/tests/kdlibtest/stacktest.cpp
+38
-0
kdlib/tests/targetapp/targetapp.cpp
kdlib/tests/targetapp/targetapp.cpp
+4
-0
kdlib/tests/targetapp/targetapp.vcxproj
kdlib/tests/targetapp/targetapp.vcxproj
+4
-0
kdlib/tests/targetapp/test_cv_allreg.cpp
kdlib/tests/targetapp/test_cv_allreg.cpp
+145
-0
kdlib/tests/targetapp/test_cv_allreg.h
kdlib/tests/targetapp/test_cv_allreg.h
+2
-0
No files found.
kdlib/tests/dumps/targetapp_test_cv_allreg_amd64/targetapp.pdb
0 → 100644
View file @
ba80c2ca
File added
kdlib/tests/dumps/targetapp_test_cv_allreg_amd64/targetapp_test_cv_allreg_amd64.cab
0 → 100644
View file @
ba80c2ca
File added
kdlib/tests/dumps/targetapp_test_cv_allreg_i386/targetapp.pdb
0 → 100644
View file @
ba80c2ca
File added
kdlib/tests/dumps/targetapp_test_cv_allreg_i386/targetapp_test_cv_allreg_i386.cab
0 → 100644
View file @
ba80c2ca
File added
kdlib/tests/kdlibtest/memdumpfixture.h
View file @
ba80c2ca
...
...
@@ -15,6 +15,8 @@ public:
static
constexpr
wchar_t
*
STACKTEST_WOW64
=
L"targetapp_stacktest_wow64"
;
static
constexpr
wchar_t
*
STACKTEST_X64_RELEASE
=
L"targetapp_stacktest_x64_release"
;
static
constexpr
wchar_t
*
STACKTEST_WOW64_RELEASE
=
L"targetapp_stacktest_wow64_release"
;
static
constexpr
wchar_t
*
STACKTEST_CV_ALLREG_I386
=
L"targetapp_test_cv_allreg_i386"
;
static
constexpr
wchar_t
*
STACKTEST_CV_ALLREG_AMD64
=
L"targetapp_test_cv_allreg_amd64"
;
static
constexpr
wchar_t
*
WIN10_ARM64
=
L"win10_arm64_mem"
;
static
constexpr
wchar_t
*
WIN10_ARM
=
L"win10_arm_rpi3_mem"
;
static
constexpr
wchar_t
*
WIN8_X64
=
L"win8_x64_mem"
;
...
...
kdlib/tests/kdlibtest/stacktest.cpp
View file @
ba80c2ca
...
...
@@ -432,3 +432,41 @@ INSTANTIATE_TEST_CASE_P(ReleaseStackDumps, InlineStackTest, ::testing::Values(
MemDumps
::
STACKTEST_X64_RELEASE
,
MemDumps
::
STACKTEST_WOW64_RELEASE
));
class
DiaRegToRegRelativei386Test
:
public
MemDumpFixture
{
public:
DiaRegToRegRelativei386Test
()
:
MemDumpFixture
(
makeDumpFullName
(
MemDumps
::
STACKTEST_CV_ALLREG_I386
))
{
}
};
TEST_F
(
DiaRegToRegRelativei386Test
,
CV_ALLREG_VFRAME
)
{
auto
stack
=
getStack
(
true
);
auto
frame
=
stack
->
getFrame
(
0
);
unsigned
long
paramCount
=
frame
->
getTypedParamCount
();
EXPECT_NE
(
0
,
paramCount
);
for
(
unsigned
long
i
=
0
;
i
<
paramCount
;
++
i
)
ASSERT_NO_THROW
(
frame
->
getTypedParam
(
i
));
}
class
DiaRegToRegRelativeAmd64Test
:
public
MemDumpFixture
{
public:
DiaRegToRegRelativeAmd64Test
()
:
MemDumpFixture
(
makeDumpFullName
(
MemDumps
::
STACKTEST_CV_ALLREG_AMD64
))
{
}
};
TEST_F
(
DiaRegToRegRelativeAmd64Test
,
CV_ALLREG_VFRAME
)
{
auto
stack
=
getStack
(
true
);
auto
frame
=
stack
->
getFrame
(
0
);
unsigned
long
localCount
=
frame
->
getLocalVarCount
();
EXPECT_NE
(
0
,
localCount
);
for
(
unsigned
long
i
=
0
;
i
<
localCount
;
++
i
)
ASSERT_NO_THROW
(
frame
->
getLocalVar
(
i
));
}
kdlib/tests/targetapp/targetapp.cpp
View file @
ba80c2ca
...
...
@@ -13,6 +13,7 @@
#include "test/testfunc.h"
#include "test/testvars.h"
#include "test_cv_allreg.h"
int
breakOnRun
();
int
breakpointTestRun
();
...
...
@@ -95,6 +96,9 @@ int _tmain(int argc, _TCHAR* argv[])
if
(
testGroup
==
L"childprocess"
)
return
startChildProcess
();
if
(
testGroup
==
L"test_cv_allreg"
)
return
test_cv_allreg
();
return
breakOnRun
();
}
...
...
kdlib/tests/targetapp/targetapp.vcxproj
View file @
ba80c2ca
...
...
@@ -155,6 +155,7 @@
<ClInclude
Include=
"..\..\include\test\testvars.h"
/>
<ClInclude
Include=
"stdafx.h"
/>
<ClInclude
Include=
"targetver.h"
/>
<ClInclude
Include=
"test_cv_allreg.h"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"..\comdate\testfunc.cpp"
>
...
...
@@ -171,6 +172,9 @@
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Create
</PrecompiledHeader>
</ClCompile>
<ClCompile
Include=
"targetapp.cpp"
/>
<ClCompile
Include=
"test_cv_allreg.cpp"
>
<WholeProgramOptimization
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
false
</WholeProgramOptimization>
</ClCompile>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
...
...
kdlib/tests/targetapp/test_cv_allreg.cpp
0 → 100644
View file @
ba80c2ca
#include "stdafx.h"
#ifndef _WIN64
#include <vector>
#include <sstream>
typedef
unsigned
long
long
MEMOFFSET_64
;
#define FAILED(x) x != 0
#define S_OK 0
typedef
int
HRESULT
;
typedef
void
*
PVOID
;
typedef
unsigned
long
ULONG
;
typedef
unsigned
long
long
ULONG64
;
typedef
HRESULT
(
*
write_mem_func_t
)(
MEMOFFSET_64
,
void
*
,
ULONG
,
unsigned
long
*
);
write_mem_func_t
WriteVirtual
=
0
;
write_mem_func_t
WritePhysical
=
0
;
typedef
HRESULT
(
*
valid_region_virtual_func_t
)(
MEMOFFSET_64
,
ULONG
,
ULONG64
*
,
ULONG
*
);
valid_region_virtual_func_t
GetValidRegionVirtual
=
0
;
__declspec
(
dllexport
)
void
setWriteFunc
(
write_mem_func_t
a
,
write_mem_func_t
b
,
valid_region_virtual_func_t
c
)
{
WriteVirtual
=
a
;
WritePhysical
=
b
;
GetValidRegionVirtual
=
c
;
}
__declspec
(
dllexport
)
MEMOFFSET_64
addr64
(
MEMOFFSET_64
offset
)
{
return
offset
;
}
template
<
typename
Dst
,
typename
Src
>
Dst
numeric_cast
(
Src
a
)
{
return
(
Dst
)
a
;
}
class
MemoryException
:
public
std
::
exception
{
public:
MemoryException
(
MEMOFFSET_64
targetAddr
,
bool
phyAddr
=
false
)
:
m_targetAddress
(
targetAddr
)
{}
MEMOFFSET_64
m_targetAddress
;
};
__declspec
(
noinline
)
bool
isVaRegionValid
(
MEMOFFSET_64
addr
,
size_t
length
)
{
addr
=
addr64
(
addr
);
HRESULT
hres
;
ULONG64
validBase
=
0
;
ULONG
validSize
=
0
;
if
(
length
>
0xFFFFFFFF
)
return
false
;
hres
=
GetValidRegionVirtual
(
addr
,
numeric_cast
<
ULONG
>
(
length
),
&
validBase
,
&
validSize
);
return
hres
==
S_OK
&&
validBase
==
addr
&&
validSize
==
length
;
}
__declspec
(
noinline
)
void
writeMemory
(
MEMOFFSET_64
offset
,
const
void
*
buffer
,
size_t
length
,
bool
phyAddr
=
false
,
unsigned
long
*
written
=
0
)
{
offset
=
addr64
(
offset
);
if
(
written
)
*
written
=
0
;
HRESULT
hres
;
if
(
phyAddr
==
false
)
{
offset
=
addr64
(
offset
);
hres
=
WriteVirtual
(
offset
,
const_cast
<
PVOID
>
(
buffer
),
numeric_cast
<
ULONG
>
(
length
),
written
);
}
else
{
hres
=
WritePhysical
(
offset
,
const_cast
<
PVOID
>
(
buffer
),
numeric_cast
<
ULONG
>
(
length
),
written
);
}
if
(
FAILED
(
hres
))
throw
MemoryException
(
offset
,
phyAddr
);
}
template
<
typename
T
>
void
writeArray
(
MEMOFFSET_64
offset
,
const
std
::
vector
<
T
>
&
values
,
bool
phyAddr
)
{
if
(
values
.
empty
())
return
;
const
auto
length
=
values
.
size
()
*
sizeof
(
T
);
if
(
!
phyAddr
&&
!
isVaRegionValid
(
offset
,
length
))
throw
MemoryException
(
offset
);
writeMemory
(
offset
,
&
values
[
0
],
length
,
phyAddr
);
}
__declspec
(
dllexport
)
void
__fastcall
test_cv_allreg_i386
(
MEMOFFSET_64
offset
,
const
std
::
vector
<
unsigned
char
>
&
values
,
bool
phyAddr
)
{
__debugbreak
();
writeArray
(
offset
,
values
,
phyAddr
);
}
int
test_cv_allreg
()
{
test_cv_allreg_i386
(
0
,
{
0
,
0
},
0
);
return
0
;
}
#else
typedef
int
(
*
dummy_subcall_t
)(
char
*
firstptr
,
char
*
lastptr
);
dummy_subcall_t
dummy_subcall
=
0
;
__declspec
(
noinline
)
int
test_cv_allreg_amd64
(
char
*
aa
,
char
*
ab
)
{
char
l
=
0
,
r
=
aa
[
0
];
char
*
e
=
ab
+
r
*
r
;
__debugbreak
();
char
*
f
,
*
lt
,
*
le
;
le
=
aa
+
aa
[
0
];
f
=
lt
=
e
;
while
(
f
>
aa
&&
dummy_subcall
(
ab
,
f
-
r
))
f
-=
r
;
while
(
lt
<
le
&&
dummy_subcall
(
ab
,
lt
+
r
))
lt
+=
r
;
return
(
f
==
lt
)
?
e
[
0
]
:
0
;
}
int
test_cv_allreg
()
{
test_cv_allreg_amd64
(
"test"
,
0
);
return
0
;
}
#endif
kdlib/tests/targetapp/test_cv_allreg.h
0 → 100644
View file @
ba80c2ca
#pragma once
int
test_cv_allreg
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment