Code: Select all
__PtrToArray = function (pBuf)
local tRet = {};
local nOffset = 0;
local nLen, pData, hData
while true do
nLen = tonumber(DLL.CallFunction("kernel32.dll", "lstrlenA", pBuf + nOffset, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
if (nLen == 0) then break; end
pData = MemoryEx.DefineStruct{STRING("char", 1 + nLen, 1, MEMEX_ASCII)};
hData = MemoryEx.AssignStruct(pBuf + nOffset, pData);
tRet[#tRet + 1] = hData.char;
hData:Close();
nOffset = nOffset + (1 + nLen);
end
return (#tRet > 0) and tRet or nil;
end