microsoft / microsoft/ConcordExtensibilitySamples
Difficulties calling function on Complex struct types such as lua_State
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 135
- Forks
- 54
- Avg merge
- 5h 58m
- Merged PRs (30d)
- 3
Description
Hi, I want to get more informations from debug value such as lua_State in Lua5.3.lib.
Following this demo, It is possibe to get the lua_State* address and following fixed size memory(BY DkmProcess::ReadMemory). But lua_State is very complicated, and is not easy to copy.
More seriously I can not call any functions from lua_State with the address because it is from another Process. As I Known,there is an old way in natvis called "LegacyAddin" which can make my debug dll and the target project run in the same peocess. But this way isn`t valid after vs 2019.
//complicated struct, there are a lot of pointers
struct lua_State {
CommonHeader;
lu_byte status;
lu_byte allowhook;
unsigned short nci; /* number of items in 'ci' list */
StkId top; /* first free slot in the stack */
global_State *l_G;
CallInfo *ci; /* call info for current function */
const Instruction *oldpc; /* last pc traced */
StkId stack_last; /* last free slot in the stack */
StkId stack; /* stack base */
UpVal *openupval; /* list of open upvalues in this stack */
GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
volatile lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
l_uint32 nCcalls; /* number of allowed nested C calls - 'nci' */
int stacksize;
int basehookcount;
int hookcount;
volatile l_signalT hookmask;
};
HRESULT STDMETHODCALLTYPE CLuaStateVisualizerService::EvaluateVisualizedExpression(
_In_ Evaluation::DkmVisualizedExpression* pVisualizedExpression,
_Deref_out_opt_ Evaluation::DkmEvaluationResult** ppResultObject
)
{
HRESULT hr;
Evaluation::DkmPointerValueHome* pPointerValueHome = Evaluation::DkmPointerValueHome::TryCast(pVisualizedExpression->ValueHome());
if (pPointerValueHome == nullptr)
{
return E_NOTIMPL;
}
DkmRootVisualizedExpression* pRootVisualizedExpression = DkmRootVisualizedExpression::TryCast(pVisualizedExpression);
if (pRootVisualizedExpression == nullptr)
{
return E_NOTIMPL;
}
// I can get the lua_State address, but
DkmProcess* pTargetProcess = pVisualizedExpression->RuntimeInstance()->Process();
lua_State* value = (lua_State*)pPointerValueHome->Address();
int n = lua_gettop(L);//Crashed , read access violation. beacuse read address from another process
Could give me any suggestions? Thanks
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with CLuaStateVisualizerService::EvaluateVisualizedExpression, DkmPointerValueHome::Address(), and DkmProcess::ReadMemory. Review how the sample handles values from another process and the stated LegacyAddin limitation after Visual Studio 2019. Done would require a defined supported approach for working with lua_State or a documented explanation of the limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- devtools, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100