A forum for reverse engineering, OS internals and malware analysis 

Forum for discussion about user-mode development.
 #12990  by native99
 Wed May 02, 2012 1:18 pm
i'm building a code in native subsystem and i have problem with operator new and delete i want to use wdk new and delete but i get this error's:

: error LNK2019: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) referenced in function _main

: error LNK2019: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) referenced in function _main

is there any way to use wdk own new and delete ??
or is there any library in wdk that i can use for these function in antive subsystem ??
 #12991  by xdeadcode
 Wed May 02, 2012 1:27 pm
Hi native99,

You CAN use your own new/delete operators.
Your error comes from linker so I suggest to check if:
a) you have same declaration and definitions in h/cpp file.
b) you are compiling your operators definitions.

I assume that you have different declaration and definition.

You can also take a look here:
http://www.osronline.com/article.cfm?article=57

Best regards
 #12993  by native99
 Wed May 02, 2012 3:58 pm
thank you for answering my question
but the problem is that i don't want to overload new and delete
and i want to know that , is there any way to use wdk 's own new and delete
because my project is a combination of c and c++ file and when i overload these functions
i've some error in some of the projects
thanks
 #12995  by xdeadcode
 Wed May 02, 2012 9:39 pm
Hi native99,

You should be aware of fact that microsoft has designed WDK framework for C.
If you want to use C++ (this is your choice) with WDK you should define your own operators new and delete since you have to know how it should work.
If your project is mix of C and C++ - still this is not a problem - you can use new/malloc and delete/free - depending on your needs and depending on how you implement it.
If you have problems with compilation/linking then post code - maybe we will be able to help you.


Best regards