Note that there are some explanatory texts on larger screens.

plurals
  1. POCall a function taking a stack object as argument with heap based data
    primarykey
    data
    text
    <p>I have a complex problem to be solve, as I am stuck and found no way at all to solve this. Here's a code</p> <pre><code>struct MyStruct { int x; float y; char c; }; void foo(MyStruct a_myStruct); int _tmain(int argc, _TCHAR* argv[]) { void *pMyStruct = malloc(sizeof(MyStruct)); int* pInt = (int*)pMyStruct; *pInt = 10; pInt++; float *pFloat = (float*)pInt; *pFloat = 2.545; pFloat++; char *pChar = (char*)pFloat; *pChar = 'c'; _asm { pMyStruct call foo } return 0; } void foo(MyStruct a_myStruct) { } </code></pre> <p>Here you can see that <code>foo</code> is operating on an object on the stack and is expecting the stack object to be mapped when <code>foo</code> gets called. But unfortunately the <code>MyStruct</code> type is not known at compile time so I have to create blocks of memory and then at runtime data is filled within that block which is then passed when <code>foo</code> gets called with asm as show above.</p> <p>Now how can I convert a heap void pointer into stack type object. Somehow if I get the address of the <code>a_myStruct</code> argument of <code>foo</code>, I can point with <code>void*</code> to that location but again I can't dereference <code>void*</code> so that it gets converted into an object of <code>MyStruct</code> type.</p> <p>Any other way around to solve the problem? As in C++ we can determine type at runtime as well.</p> <hr> <p>I have a problem to call functions at run time in C++ which might have signature with full of user defined types that are not known at compile time.But details of those types are available to me(As I deciphered details of certain type from type library or from DIA SDK). But the main problem is now i want to call these functions at runtime. At compile time I just have address of function and details of user defined type of which object or pointer is participating as argument of that function signature. Now If i want to call that function at run time, i need to populate that type at runtime first by creating temporary block on heap and filling that block with the data .I have all details of that type.</p> <p>Now problem is i don't know that function taking argument as pointer of that type of which I have details available or that argument is exactly the stack object of that type. If i have pointer to that type no problem, but if object there i have big problem to call that function at runtime.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload