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
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.
Could give me any suggestions? Thanks