c++ cli - DLL import failure in using WinDivert -



c++ cli - DLL import failure in using WinDivert -

i going design programme using windivert manipulate network traffic. language utilize c++ , programme designed under visual studio 2008. firstly create project in visual c++ clr (windows forms application) can implement ui simply.

for importing windirvert library, have done next setting in project properties:

configuaration properties: general mutual language runtime support: mutual language runtime support(/ctr) configuaration properties: linker additional dependencies: link of windivert.lib module definition file: link of windivert.def

within project have created, added windivert.h in header files.

also, windivert.h included in main entry point of project (projectg.cpp):

#include "stdafx.h" #include "form1.h" #pragma managed(push, off) #include "windivert.h" #pragma managed(pop) using namespace projectg; [stathreadattribute] int main(array<system::string ^> ^args) { // enabling windows xp visual effects before controls created application::enablevisualstyles(); application::setcompatibletextrenderingdefault(false); // create main window , run application::run(gcnew form1()); handle handle; unsigned char packet[8192]; uint packet_len; windivert_address addr; handle = windivertopen("udp", windivert_layer_network, 0, windivert_flag_drop); if (handle == invalid_handle_value) { application::exit(); } while (true) { // read matching packet. if (!windivertrecv(handle, packet, sizeof(packet), &addr, &packet_len)) { messagebox::show("fail"); continue; } } homecoming 0; }

finally, set {windivert.dll, windivert.h, windivert.lib, windivert32.sys} under project directory.

however, next error shown:

fatal error lnk1306: dll entry point "int __clrcall main(cli::array<class system::string ^ >^)" (?main@@$$hymhp$01ap$aavstring@system@@@z) cannot managed; compile native projectg.obj projectg

additional: (a warning)

warning lnk4070: /out:windivert.dll directive in .exp differs output filename 'c:\users\david\desktop\css\projectg\debug\projectg.exe'; ignoring directive projectg.exp projectg

question: how can resolve situation?

a) main source .cpp, can delete [stathreadattribute] , change int main(array<system::string ^> ^args) int _tmain(int argc, _tchar* argv[])

b) exclude windivert.def linker module definition file, when creating dll

c) dll/sys files need copied debug , release folders

c++-cli dllimport unmanaged wfp

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -