64位问题

编程入门 行业动态 更新时间:2024-10-18 18:26:34
本文介绍了64位问题_alloca问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在VC ++ 2010中的X64代码中遇到问题.我的32位代码工作正常,但在64位中,我具有动态分配的功能,如下所示.我有一个具有两个参数的函数,我可以使用加载库加载dll运行时.当我获取价值时,我的第二个论点 被第一个替换,第二个参数包含垃圾值.我的要求是我必须在运行时使用动态参数列表加载dll函数.以下是我的代码

I have problem in X64 code in VC++ 2010. My code in 32 bit works fine but in 64 i have function with dynamical allocation as under. I have a function having two parameter i to load dll runtime using load library. When i retrieve value my second argument is replaced by first and my second argument contain garbage value. My requirement is that i have to load dll functions on runtime with dynamic list of parameters. Below is my code

FARPROC pProcAddr;

FARPROC pProcAddr;

pProcAddr = GetProcAddress(hInstance,"function1"))))

pProcAddr = GetProcAddress( hInstance,"function1" ) ) )

p缓冲所有参数.

nBufferSize是缓冲区大小

nBufferSize is buffer size

LPVOID pStack = _alloca(nBufferSize); //在堆栈上分配参数块

LPVOID pStack = _alloca( nBufferSize ); // Allocate parameter block on a stack

memcpy(pStack,pBuffer,nBufferSize); //将参数块复制到堆栈中

memcpy( pStack, pBuffer, nBufferSize ); // Copy parameter block to stack

//功能调用

pReturn =(* pProcAddr)();

pReturn = (*pProcAddr)();

此致

法赫德·安瓦尔

Fahd Anwar

推荐答案

问题不在于alloca,而在于x86和x64之间的调用约定.您应该阅读以下内容:

The problem is not alloca but the difference in calling convention between x86 and x64. You should read the following:

msdn.microsoft /en-US/library/ms235286(v=VS.100).aspx

但是我不确定您想做的事是否确实可行. x64调用约定使用寄存器来传递某些参数,并且x64编译器不允许内联汇编程序.我看不到如何模拟函数调用 这种情况.

but I'm not sure if what you want to do is actually possible. The x64 calling convention uses registers to pass some of the arguments and at the same the x64 compiler doesn't allow inline assembler. I don't see how you could simulate a function callin this circumstances.

更多推荐

64位问题

本文发布于:2023-11-11 23:06:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!