本文介绍了MASM DLL内存分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用我的MASM DLL帮助。我指望在数组中的元素,然后我要为另一个数组分配内存,在C我使用向量。
我试图用

I need help with my MASM dll. I'm counting elements in array then I want to allocate memory for another array, in C I'm using vector.I tried to use:

invoe GetProcessHeap
invoke HeapAlloc, eax, HEAP_NO_SERIALIZE + HEAP_ZERO_MEMORY, <size>

invoke GlobalAlloc, GMEM_ZEROINIT, <size>
mov tab, eax

但我发现了错误未定义的符号:GetProcessHeap 未定义的符号:HeapAlloc

我使用C#应用程序这个库。
你能告诉我的例子,我怎么能动态分配内存?

I'm using this library in C# application.Can you show me example how can I dynamically allocate memory?

推荐答案

您需要对相应的​​库链接。如果你看一下你会看到它位于 KERNEL32.DLL

You need to link against the appropriate library. If you look at the MSDN page for HeapAlloc you'll see that it's located in kernel32.dll.

假设你正在使用MASM32应该有一个 kernel32.inc (的程序原型)和 KERNEL32.LIB (用于连接)附带的安装MASM32。所以,你需要以下几行添加到您的程序集文件:

Assuming that you're using MASM32 there should be a kernel32.inc (for the procedure prototype) and kernel32.lib (for linking) included with your MASM32 installation. So you need to add the following lines to your assembly file:

include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

如果你没有一个 KERNEL32.LIB 文件,它变得更复杂一些,但它仍然是可行的,通过使用调用LoadLibrary 加载 KERNEL32.DLL ,然后用 HeapAlloc 函数的地址> GetProcAddress的。

If you don't have a kernel32.lib file it gets a bit more complicated, but it's still doable by using LoadLibrary to load kernel32.dll and then getting the address of the HeapAlloc function with GetProcAddress.

这篇关于MASM DLL内存分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 15:15