Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions inc/fnsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,29 @@ EXTERN_C_START

#endif

#ifndef FNSOCKAPI
#define FNSOCKAPI __declspec(dllimport)
#endif

DECLARE_HANDLE(FNSOCK_HANDLE);

FNSOCKAPI
PAGEDX
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockInitialize(
VOID
);

FNSOCKAPI
PAGEDX
_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
FnSockUninitialize(
VOID
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockCreate(
Expand All @@ -136,12 +143,14 @@ FnSockCreate(
_Out_ FNSOCK_HANDLE* Socket
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
FnSockClose(
_In_ FNSOCK_HANDLE Socket
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockBind(
Expand All @@ -150,6 +159,7 @@ FnSockBind(
_In_ INT AddressLength
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockGetSockName(
Expand All @@ -158,6 +168,7 @@ FnSockGetSockName(
_Inout_ INT* AddressLength
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockSetSockOpt(
Expand All @@ -168,6 +179,7 @@ FnSockSetSockOpt(
_In_ SIZE_T OptionLength
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockGetSockOpt(
Expand All @@ -178,6 +190,7 @@ FnSockGetSockOpt(
_Inout_ SIZE_T* OptionLength
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockIoctl(
Expand All @@ -190,13 +203,15 @@ FnSockIoctl(
_Out_ ULONG* BytesReturned
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockListen(
_In_ FNSOCK_HANDLE Socket,
_In_ ULONG Backlog
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_HANDLE
FnSockAccept(
Expand All @@ -205,13 +220,15 @@ FnSockAccept(
_Inout_ INT* AddressLength
);

FNSOCKAPI
FNSOCK_STATUS
FnSockConnect(
_In_ FNSOCK_HANDLE Socket,
_In_reads_bytes_(AddressLength) struct sockaddr* Address,
_In_ INT AddressLength
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockSend(
Expand All @@ -222,6 +239,7 @@ FnSockSend(
_In_ INT Flags
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockSendto(
Expand All @@ -234,6 +252,7 @@ FnSockSendto(
_In_ INT AddressLength
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockRecv(
Expand All @@ -244,6 +263,7 @@ FnSockRecv(
_In_ INT Flags
);

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockGetLastError(
Expand Down
5 changes: 5 additions & 0 deletions src/sock/km/fnsock_km.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LIBRARY fnsock_km.sys

EXPORTS
DllInitialize PRIVATE
DllUnload PRIVATE
15 changes: 14 additions & 1 deletion src/sock/km/fnsock_km.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
<PropertyGroup>
<ProjectGuid>{ac661767-42c3-4525-8b90-d509a6048dc3}</ProjectGuid>
<TargetName>fnsock_km</TargetName>
<UndockedType>drvlib</UndockedType>
<UndockedType>sys</UndockedType>
<UndockedDir>$(SolutionDir)submodules\undocked\</UndockedDir>
<UndockedOut>$(SolutionDir)artifacts\</UndockedOut>
<UndockedSourceLink>true</UndockedSourceLink>
</PropertyGroup>
<Import Project="$(UndockedDir)vs\windows.undocked.props" />
<Import Project="$(SolutionDir)src\wnt.cpp.props" />
<Import Project="$(SolutionDir)src\wnt.cpp.kernel.props" />
<ItemGroup>
<ProjectReference Include="$(SolutionDir)src\wskclient\wskclient.vcxproj">
<Project>{50f8f5ee-aa31-427f-9959-13de0d68bd06}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="sock.c" />
</ItemGroup>
Expand All @@ -27,6 +32,14 @@
<WppRecorderEnabled>true</WppRecorderEnabled>
<WppAdditionalOptions>-p:fnsock</WppAdditionalOptions>
</ClCompile>
<Link>
<ModuleDefinitionFile>fnsock_km.def</ModuleDefinitionFile>
<AdditionalDependencies>
netio.lib;
uuid.lib;
%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(UndockedDir)vs\windows.undocked.targets" />
</Project>
49 changes: 49 additions & 0 deletions src/sock/km/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <ntddk.h>
#include <wsk.h>

#define FNSOCKAPI __declspec(dllexport)

#include "fnsock.h"
#include "pooltag.h"
#include "trace.h"
Expand Down Expand Up @@ -109,6 +111,38 @@ FnSockStreamSocketReceive(
_Inout_ SIZE_T* BytesAccepted
);

_Function_class_(DRIVER_INITIALIZE)
_IRQL_requires_same_
_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
DriverEntry(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you don't have a driver service, I think the DriverEntry isn't necessary, but since it doesn't hurt we can leave it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unused (not called), but the driver framework seems to expect it

    2>WdfDriverEntry.lib(stub.obj) : error LNK2019: unresolved external symbol DriverEntry referenced in function FxDr
       iverEntryWorker [N:\repos\win-net-test\src\sock\km\fnsock_km.vcxproj]
     2>N:\repos\win-net-test\artifacts\bin\amd64chk\fnsock_km.sys : fatal error LNK1120: 1 unresolved externals [N:\rep
       os\win-net-test\src\sock\km\fnsock_km.vcxproj]

_In_ struct _DRIVER_OBJECT *DriverObject,
_In_ UNICODE_STRING *RegistryPath
)
{
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath);
return STATUS_SUCCESS;
}

NTSTATUS
DllInitialize(
_In_ PUNICODE_STRING RegistryPath
)
{
UNREFERENCED_PARAMETER(RegistryPath);
return STATUS_SUCCESS;
}

NTSTATUS
DllUnload(
VOID
)
{
return STATUS_SUCCESS;
}

FNSOCKAPI
PAGEDX
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
Expand All @@ -132,6 +166,7 @@ FnSockInitialize(
return WskClientReg();
}

FNSOCKAPI
PAGEDX
_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
Expand Down Expand Up @@ -169,6 +204,7 @@ InitializeBinding(
InitializeListHead(&Binding->SendContextList);
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockCreate(
Expand Down Expand Up @@ -248,6 +284,7 @@ FnSockCreate(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
FnSockClose(
Expand Down Expand Up @@ -325,6 +362,7 @@ FnSockClose(
ExFreePoolWithTag(Binding, POOLTAG_FNSOCK_SOCKET);
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockBind(
Expand Down Expand Up @@ -380,6 +418,7 @@ FnSockBind(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockGetSockName(
Expand Down Expand Up @@ -416,6 +455,7 @@ FnSockGetSockName(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockSetSockOpt(
Expand Down Expand Up @@ -474,6 +514,7 @@ FnSockSetSockOpt(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockGetSockOpt(
Expand Down Expand Up @@ -535,6 +576,7 @@ FnSockGetSockOpt(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockIoctl(
Expand Down Expand Up @@ -583,6 +625,7 @@ FnSockIoctl(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_STATUS
FnSockListen(
Expand Down Expand Up @@ -631,6 +674,7 @@ FnSockListen(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
FNSOCK_HANDLE
FnSockAccept(
Expand Down Expand Up @@ -726,6 +770,7 @@ FnSockAccept(
return (FNSOCK_HANDLE)NewBinding;
}

FNSOCKAPI
FNSOCK_STATUS
FnSockConnect(
_In_ FNSOCK_HANDLE Socket,
Expand Down Expand Up @@ -794,6 +839,7 @@ FnSockConnect(
return Status;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockSend(
Expand Down Expand Up @@ -872,6 +918,7 @@ FnSockSend(
return BytesSent;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockSendto(
Expand Down Expand Up @@ -954,6 +1001,7 @@ FnSockSendto(
return BytesSent;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockRecv(
Expand Down Expand Up @@ -1497,6 +1545,7 @@ NtStatusToSocketError(
return err;
}

FNSOCKAPI
_IRQL_requires_max_(PASSIVE_LEVEL)
INT
FnSockGetLastError(
Expand Down
8 changes: 7 additions & 1 deletion src/sock/um/fnsock_um.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<ProjectGuid>{dca385fb-b4b1-44cc-ba3f-9da4f619d86a}</ProjectGuid>
<TargetName>fnsock_um</TargetName>
<UndockedType>lib</UndockedType>
<UndockedType>dll</UndockedType>
<UndockedDir>$(SolutionDir)submodules\undocked\</UndockedDir>
<UndockedOut>$(SolutionDir)artifacts\</UndockedOut>
<UndockedSourceLink>true</UndockedSourceLink>
Expand All @@ -26,6 +26,12 @@
%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>
ws2_32.lib;
%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(UndockedDir)vs\windows.undocked.targets" />
</Project>
Loading