Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
P
pykd-ext
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Todd Hartman
pykd-ext
Commits
0ae113c9
Commit
0ae113c9
authored
Feb 07, 2019
by
ussrhero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix crash with convert bytearry to string on python 3
parent
b0fdd53a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
7 deletions
+46
-7
sources/pyapi.h
sources/pyapi.h
+3
-0
sources/pyclass.h
sources/pyclass.h
+24
-4
sources/pyinterpret.cpp
sources/pyinterpret.cpp
+16
-0
sources/pykd_ext.vcxproj
sources/pykd_ext.vcxproj
+2
-2
sources/version.h
sources/version.h
+1
-1
No files found.
sources/pyapi.h
View file @
0ae113c9
...
...
@@ -31,6 +31,9 @@ PyObject* __stdcall PyString_FromString(const char *v);
char
*
PyString_AsString
(
PyObject
*
string
);
int
PyString_Check
(
PyObject
*
o
);
int
__stdcall
PyBytes_Check
(
PyObject
*
bytes
);
char
*
PyBytes_AsString
(
PyObject
*
bytes
);
PyObject
*
PyImport_Import
(
PyObject
*
name
);
PyObject
*
__stdcall
PyImport_ImportModule
(
const
char
*
name
);
PyObject
*
__stdcall
PyImport_AddModule
(
const
char
*
name
);
...
...
sources/pyclass.h
View file @
0ae113c9
...
...
@@ -31,9 +31,19 @@ struct convert_from_python
return
std
::
wstring
(
&
buf
[
0
],
len
);
}
if
(
!
IsPy3
()
&&
PyString_Check
(
m_obj
)
)
if
(
!
IsPy3
(
)
)
{
return
std
::
wstring
(
_bstr_t
(
PyString_AsString
(
m_obj
)));
if
(
PyString_Check
(
m_obj
))
{
return
std
::
wstring
(
_bstr_t
(
PyString_AsString
(
m_obj
)));
}
}
else
{
if
(
PyBytes_Check
(
m_obj
))
{
return
std
::
wstring
(
_bstr_t
(
PyBytes_AsString
(
m_obj
)));
}
}
throw
convert_python_exception
(
"failed convert argument"
);
...
...
@@ -51,9 +61,19 @@ struct convert_from_python
return
std
::
string
(
_bstr_t
(
str
.
c_str
()));
}
if
(
!
IsPy3
()
&&
PyString_Check
(
m_obj
)
)
if
(
!
IsPy3
())
{
if
(
PyString_Check
(
m_obj
))
{
return
std
::
string
(
PyString_AsString
(
m_obj
));
}
}
else
{
return
std
::
string
(
PyString_AsString
(
m_obj
));
if
(
PyBytes_Check
(
m_obj
))
{
return
std
::
string
(
PyBytes_AsString
(
m_obj
));
}
}
throw
convert_python_exception
(
"failed convert argument"
);
...
...
sources/pyinterpret.cpp
View file @
0ae113c9
...
...
@@ -65,6 +65,7 @@ public:
PyObject
*
PyExc_TypeError
;
PyObject
*
PyUnicode_Type
;
PyObject
*
PyString_Type
;
PyObject
*
PyBytes_Type
;
PyThreadState
**
PyThreadState_Current
;
...
...
@@ -105,6 +106,7 @@ public:
void
(
*
PySys_SetArgv_Py3
)(
int
argc
,
wchar_t
**
argv
);
PyObject
*
(
*
PyString_FromString
)(
const
char
*
v
);
char
*
(
*
PyString_AsString
)(
PyObject
*
string
);
char
*
(
*
PyBytes_AsString
)(
PyObject
*
bytes
);
void
(
*
PyErr_Fetch
)(
PyObject
**
ptype
,
PyObject
**
pvalue
,
PyObject
**
ptraceback
);
void
(
*
PyErr_NormalizeException
)(
PyObject
**
exc
,
PyObject
**
val
,
PyObject
**
tb
);
void
(
*
PyErr_SetString
)(
PyObject
*
type
,
const
char
*
message
);
...
...
@@ -416,6 +418,8 @@ PyModule::PyModule(int majorVesion, int minorVersion)
*
reinterpret_cast
<
FARPROC
*>
(
&
PyProperty_Type
)
=
GetProcAddress
(
m_handlePython
,
"PyProperty_Type"
);
*
reinterpret_cast
<
FARPROC
*>
(
&
PyUnicode_Type
)
=
GetProcAddress
(
m_handlePython
,
"PyUnicode_Type"
);
*
reinterpret_cast
<
FARPROC
*>
(
&
PyString_Type
)
=
GetProcAddress
(
m_handlePython
,
"PyString_Type"
);
*
reinterpret_cast
<
FARPROC
*>
(
&
PyBytes_Type
)
=
isPy3
?
GetProcAddress
(
m_handlePython
,
"PyBytes_Type"
)
:
0
;
*
reinterpret_cast
<
FARPROC
*>
(
&
Py_None
)
=
GetProcAddress
(
m_handlePython
,
"_Py_NoneStruct"
);
PyExc_SystemExit
=
*
reinterpret_cast
<
PyObject
**>
(
GetProcAddress
(
m_handlePython
,
"PyExc_SystemExit"
));
PyExc_TypeError
=
*
reinterpret_cast
<
PyObject
**>
(
GetProcAddress
(
m_handlePython
,
"PyExc_TypeError"
));
...
...
@@ -456,6 +460,7 @@ PyModule::PyModule(int majorVesion, int minorVersion)
*
reinterpret_cast
<
FARPROC
*>
(
&
PySys_SetArgv_Py3
)
=
isPy3
?
GetProcAddress
(
m_handlePython
,
"PySys_SetArgv"
)
:
0
;
*
reinterpret_cast
<
FARPROC
*>
(
&
PyString_FromString
)
=
GetProcAddress
(
m_handlePython
,
"PyString_FromString"
);
*
reinterpret_cast
<
FARPROC
*>
(
&
PyString_AsString
)
=
GetProcAddress
(
m_handlePython
,
"PyString_AsString"
);
*
reinterpret_cast
<
FARPROC
*>
(
&
PyBytes_AsString
)
=
isPy3
?
GetProcAddress
(
m_handlePython
,
"PyBytes_AsString"
)
:
0
;
*
reinterpret_cast
<
FARPROC
*>
(
&
PyErr_Fetch
)
=
GetProcAddress
(
m_handlePython
,
"PyErr_Fetch"
);
*
reinterpret_cast
<
FARPROC
*>
(
&
PyErr_NormalizeException
)
=
GetProcAddress
(
m_handlePython
,
"PyErr_NormalizeException"
);
*
reinterpret_cast
<
FARPROC
*>
(
&
PyErr_SetString
)
=
GetProcAddress
(
m_handlePython
,
"PyErr_SetString"
);
...
...
@@ -754,6 +759,11 @@ char* PyString_AsString(PyObject *string)
return
PythonSingleton
::
get
()
->
currentInterpreter
()
->
m_module
->
PyString_AsString
(
string
);
}
char
*
PyBytes_AsString
(
PyObject
*
bytes
)
{
return
PythonSingleton
::
get
()
->
currentInterpreter
()
->
m_module
->
PyBytes_AsString
(
bytes
);
}
PyObject
*
PyUnicode_FromWideChar
(
const
wchar_t
*
w
,
size_t
size
)
{
return
PythonSingleton
::
get
()
->
currentInterpreter
()
->
m_module
->
PyUnicode_FromWideChar
(
w
,
size
);
...
...
@@ -922,3 +932,9 @@ int PyUnicode_Check(PyObject *o)
PythonSingleton
::
get
()
->
currentInterpreter
()
->
m_module
->
PyUnicode_Type
);
}
int
PyBytes_Check
(
PyObject
*
o
)
{
return
PythonSingleton
::
get
()
->
currentInterpreter
()
->
m_module
->
PyObject_IsInstance
(
o
,
PythonSingleton
::
get
()
->
currentInterpreter
()
->
m_module
->
PyBytes_Type
);
}
sources/pykd_ext.vcxproj
View file @
0ae113c9
...
...
@@ -164,7 +164,7 @@
<OptimizeReferences>
true
</OptimizeReferences>
<ModuleDefinitionFile>
export.def
</ModuleDefinitionFile>
<OutputFile>
$(OutDir)pykd$(TargetExt)
</OutputFile>
<AdditionalDependencies>
comsuppw.lib;%(AdditionalDependencies)
</AdditionalDependencies>
<AdditionalDependencies>
dbgeng.lib;
comsuppw.lib;%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
...
...
@@ -221,5 +221,5 @@
<ErrorText>
This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
</ErrorText>
</PropertyGroup>
<Error
Condition=
"!Exists('$(SolutionDir)\packages\boost.1.67.0.0\build\boost.targets')"
Text=
"$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\boost.1.67.0.0\build\boost.targets'))"
/>
</Target>
</Target>
</Project>
\ No newline at end of file
sources/version.h
View file @
0ae113c9
...
...
@@ -3,7 +3,7 @@
#define PYKDEXT_VERSION_MAJOR 2
#define PYKDEXT_VERSION_MINOR 0
#define PYKDEXT_VERSION_SUBVERSION 0
#define PYKDEXT_VERSION_BUILDNO 2
0
#define PYKDEXT_VERSION_BUILDNO 2
1
#define __VER_STR2__(x) #x
#define __VER_STR1__(x) __VER_STR2__(x)
...
...
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