0

I am trying to create a driver using WDK.I need to use malloc in that driver.When I try to use that I got an error like malloc unresolved external symbol.I think that I have to include some library.But I am not sure .How can I resolve this error?

raji
  • 101
  • 1
  • 4
  • 14
  • This is technically not a duplicate. The OP was trying to resolve a linker issue that is specific to the WDK. The dupe'd question is for more generic linking problems. – selbie Mar 16 '13 at 22:24

1 Answers1

9

Windows Device drivers don't normally link with the C-Runtime. The build environment for the DDK/WDK doesn't link with MSVCRT. But there are memory allocation routines that can be used in kernel and driver programming.

See this link for more details.

Side note:

I'm a bit worried that you did not mention that "free" was also an unresolved symbol. That suggests that you never call it, hence a memory leak in device driver code. ;) Or does the WDK pull in an implementation of free() from somewhere?

selbie
  • 100,020
  • 15
  • 103
  • 173
  • @darkendemon - How about a big green checkbox to return the favor? – selbie Mar 16 '13 at 06:18
  • I have used MmAllocateNonCachedMemory to allocate memory.I forget to use Free .I do not know which function i have to use to free memory in driver programming .Can u guide me ?.I am new to driver programming. – raji Mar 16 '13 at 06:23
  • MmFreeNonCachedMemory - http://msdn.microsoft.com/en-us/library/windows/hardware/ff554516%28v=vs.85%29.aspx – selbie Mar 16 '13 at 07:01
  • :I am using MmAllocateNonCachedMemory and MmFreeNonCachedMemory its through exception .What type exception handling i have to use to catch that – raji Apr 14 '13 at 10:19
  • What would be the equivalent of realloc? – DreTaX May 21 '20 at 11:17