From 90b9547087ac0c7eb18997dd869b5024c3cbf380 Mon Sep 17 00:00:00 2001 From: Netch Date: Mon, 19 Jul 2021 05:18:27 +0800 Subject: [PATCH] Update Redirector --- Redirector/Data.cpp | 8 +++ Redirector/Data.h | 16 ++++++ Redirector/EventHandler.cpp | 3 ++ Redirector/EventHandler.h | 5 ++ Redirector/IPEventHandler.cpp | 5 ++ Redirector/IPEventHandler.h | 5 ++ Redirector/Redirector.cpp | 70 +++++++++++++++++++++++++++ Redirector/Redirector.vcxproj | 31 ++++++++++-- Redirector/Redirector.vcxproj.filters | 42 +++++++++++++--- Redirector/Utils.cpp | 19 ++++++++ Redirector/Utils.h | 8 +++ Redirector/main.c | 6 --- 12 files changed, 199 insertions(+), 19 deletions(-) create mode 100644 Redirector/Data.cpp create mode 100644 Redirector/Data.h create mode 100644 Redirector/EventHandler.cpp create mode 100644 Redirector/EventHandler.h create mode 100644 Redirector/IPEventHandler.cpp create mode 100644 Redirector/IPEventHandler.h create mode 100644 Redirector/Redirector.cpp create mode 100644 Redirector/Utils.cpp create mode 100644 Redirector/Utils.h delete mode 100644 Redirector/main.c diff --git a/Redirector/Data.cpp b/Redirector/Data.cpp new file mode 100644 index 00000000..a3baeb6e --- /dev/null +++ b/Redirector/Data.cpp @@ -0,0 +1,8 @@ +#include "Data.h" + +BOOL filterLoopback = FALSE; +BOOL filterICMP = TRUE; +BOOL filterTCP = TRUE; +BOOL filterUDP = TRUE; +USHORT tcpLisn = 0; +USHORT udpLisn = 0; diff --git a/Redirector/Data.h b/Redirector/Data.h new file mode 100644 index 00000000..e51d8eb2 --- /dev/null +++ b/Redirector/Data.h @@ -0,0 +1,16 @@ +#pragma once +#ifndef DATA_H +#define DATA_H +#include +#include + +enum { + AIO_FILTERLOOPBACK, + AIO_FILTERICMP, + AIO_FILTERTCP, + AIO_FILTERUDP, + AIO_TCPLISN, + AIO_UDPLISN +}; + +#endif diff --git a/Redirector/EventHandler.cpp b/Redirector/EventHandler.cpp new file mode 100644 index 00000000..60f64699 --- /dev/null +++ b/Redirector/EventHandler.cpp @@ -0,0 +1,3 @@ +#include "EventHandler.h" + +#include "Data.h" diff --git a/Redirector/EventHandler.h b/Redirector/EventHandler.h new file mode 100644 index 00000000..b26d2c91 --- /dev/null +++ b/Redirector/EventHandler.h @@ -0,0 +1,5 @@ +#pragma once +#ifndef EVENTHANDLER_H +#define EVENTHANDLER_H + +#endif diff --git a/Redirector/IPEventHandler.cpp b/Redirector/IPEventHandler.cpp new file mode 100644 index 00000000..8b58e17e --- /dev/null +++ b/Redirector/IPEventHandler.cpp @@ -0,0 +1,5 @@ +#include "IPEventHandler.h" + +#include "Data.h" +#include "Utils.h" + diff --git a/Redirector/IPEventHandler.h b/Redirector/IPEventHandler.h new file mode 100644 index 00000000..299c67ab --- /dev/null +++ b/Redirector/IPEventHandler.h @@ -0,0 +1,5 @@ +#pragma once +#ifndef IPEVENTHANDLER_H +#define IPEVENTHANDLER_H + +#endif diff --git a/Redirector/Redirector.cpp b/Redirector/Redirector.cpp new file mode 100644 index 00000000..ced67afe --- /dev/null +++ b/Redirector/Redirector.cpp @@ -0,0 +1,70 @@ +#include "Data.h" +#include "Utils.h" +#include "EventHandler.h" + +extern BOOL filterLoopback; +extern BOOL filterICMP; +extern BOOL filterTCP; +extern BOOL filterUDP; +extern USHORT tcpLisn; +extern USHORT udpLisn; + +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(hModule); + UNREFERENCED_PARAMETER(ul_reason_for_call); + UNREFERENCED_PARAMETER(lpReserved); + + return TRUE; +} + +#ifdef __cplusplus +extern "C" { +#endif + +__declspec(dllexport) BOOL __cdecl aio_dial(INT name, LPWSTR value) +{ + UNREFERENCED_PARAMETER(name); + UNREFERENCED_PARAMETER(value); + + switch (name) + { + case AIO_FILTERLOOPBACK: + break; + case AIO_FILTERICMP: + break; + case AIO_FILTERTCP: + break; + case AIO_FILTERUDP: + break; + case AIO_TCPLISN: + break; + case AIO_UDPLISN: + break; + default: + return FALSE; + } + + return TRUE; +} + +__declspec(dllexport) BOOL __cdecl aio_init() +{ + { + WSADATA data; + UNREFERENCED_PARAMETER(WSAStartup(MAKEWORD(2, 2), &data)); + } + + return FALSE; +} + +__declspec(dllexport) VOID __cdecl aio_free() +{ + UNREFERENCED_PARAMETER(WSACleanup()); + + return; +} + +#ifdef __cplusplus +} +#endif diff --git a/Redirector/Redirector.vcxproj b/Redirector/Redirector.vcxproj index 4ca58835..ea8d8f6f 100644 --- a/Redirector/Redirector.vcxproj +++ b/Redirector/Redirector.vcxproj @@ -19,13 +19,13 @@ - Application + DynamicLibrary true v142 Unicode - Application + DynamicLibrary false v142 true @@ -47,15 +47,21 @@ true $(ProjectDir)bin\ $(ProjectDir)obj\ + .bin + $(ProjectDir)include\;$(IncludePath) + $(ProjectDir)lib\;$(LibraryPath) false $(ProjectDir)bin\ $(ProjectDir)obj\ + .bin + $(ProjectDir)include\;$(IncludePath) + $(ProjectDir)lib\;$(LibraryPath) - Level3 + Level4 true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true @@ -66,11 +72,12 @@ Console true + ws2_32.lib;%(AdditionalDependencies) - Level3 + Level4 true true true @@ -85,10 +92,24 @@ true true true + ws2_32.lib;%(AdditionalDependencies) + + COPY /Y $(ProjectDir)static\*.dll $(TargetDir) > NUL + - + + + + + + + + + + + diff --git a/Redirector/Redirector.vcxproj.filters b/Redirector/Redirector.vcxproj.filters index 62e77b84..9a8b7803 100644 --- a/Redirector/Redirector.vcxproj.filters +++ b/Redirector/Redirector.vcxproj.filters @@ -1,22 +1,48 @@  - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - + {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - 源文件 + + Source + + + Source + + + Source + + + Source + + + Source + + + Header + + + Header + + + Header + + + Header + + \ No newline at end of file diff --git a/Redirector/Utils.cpp b/Redirector/Utils.cpp new file mode 100644 index 00000000..918ede0f --- /dev/null +++ b/Redirector/Utils.cpp @@ -0,0 +1,19 @@ +#include "Utils.h" + +#include "Data.h" + +USHORT IPv4Checksum(PBYTE buffer, ULONG64 size) +{ + UNREFERENCED_PARAMETER(buffer); + UNREFERENCED_PARAMETER(size); + + return 0; +} + +USHORT ICMPChecksum(PBYTE buffer, ULONG64 size) +{ + UNREFERENCED_PARAMETER(buffer); + UNREFERENCED_PARAMETER(size); + + return 0; +} diff --git a/Redirector/Utils.h b/Redirector/Utils.h new file mode 100644 index 00000000..0fc2768e --- /dev/null +++ b/Redirector/Utils.h @@ -0,0 +1,8 @@ +#pragma once +#ifndef UTILS_H +#define UTILS_H + +USHORT IPv4Checksum(PBYTE buffer, ULONG64 size); +USHORT ICMPChecksum(PBYTE buffer, ULONG64 size); + +#endif diff --git a/Redirector/main.c b/Redirector/main.c deleted file mode 100644 index 9de41917..00000000 --- a/Redirector/main.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, const char* argv[]) -{ - return EXIT_SUCCESS; -}