Skip to content

Commit 4c8e97b

Browse files
authored
prelease to release (#4)
#3
1 parent 26b4998 commit 4c8e97b

14 files changed

+499
-249
lines changed

ForTun/ForTun.inf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Class=Net
88
ClassGuid={4d36e972-e325-11ce-bfc1-08002be10318}
99
Provider=%ManufacturerName%
1010
CatalogFile=ForTun.cat
11-
;DriverVer=0.0.1
1211
PnpLockdown=1
1312

1413
[DestinationDirs]

ForTun/ForTun.vcxproj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</ProjectConfiguration>
2020
</ItemGroup>
2121
<ItemGroup>
22+
<None Include="fortun.ddf" />
2223
<None Include="ReadMe.txt" />
2324
</ItemGroup>
2425
<ItemGroup>
@@ -44,7 +45,9 @@
4445
<ClInclude Include="TXQueue.h" />
4546
</ItemGroup>
4647
<ItemGroup>
47-
<Inf Include="ForTun.inf" />
48+
<Inf Include="ForTun.inf">
49+
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">*</TimeStamp>
50+
</Inf>
4851
</ItemGroup>
4952
<PropertyGroup Label="Globals">
5053
<ProjectGuid>{4EF57910-A75E-48FB-89A0-B4005D9F609B}</ProjectGuid>
@@ -113,6 +116,7 @@
113116
</PropertyGroup>
114117
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
115118
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
119+
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
116120
</PropertyGroup>
117121
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
118122
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
@@ -131,6 +135,12 @@
131135
<DriverSign>
132136
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
133137
</DriverSign>
138+
<Inf>
139+
<SpecifyDriverVerDirectiveVersion>true</SpecifyDriverVerDirectiveVersion>
140+
</Inf>
141+
<Inf>
142+
<TimeStamp>*</TimeStamp>
143+
</Inf>
134144
</ItemDefinitionGroup>
135145
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
136146
<ClCompile>
@@ -142,6 +152,9 @@
142152
<DriverSign>
143153
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
144154
</DriverSign>
155+
<Inf>
156+
<TimeStamp>$(FOR_TUN_VERSION_MAJOR).$(FOR_TUN_VERSION_MINOR).$(FOR_TUN_VERSION_PATCH)</TimeStamp>
157+
</Inf>
145158
</ItemDefinitionGroup>
146159
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
147160
<ClCompile>

ForTun/ForTun.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</ItemGroup>
2121
<ItemGroup>
2222
<None Include="ReadMe.txt" />
23+
<None Include="fortun.ddf" />
2324
</ItemGroup>
2425
<ItemGroup>
2526
<Inf Include="ForTun.inf">

ForTun/Queue.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Return Value:
6666
//
6767
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(
6868
&queueConfig,
69+
//WdfIoQueueDispatchParallel
6970
WdfIoQueueDispatchSequential
7071
);
7172

@@ -94,10 +95,7 @@ Return Value:
9495
TraceEvents(TRACE_LEVEL_ERROR, TRACE_QUEUE, "create read queue failed %!STATUS!", status);
9596
return status;
9697
}
97-
//status = WdfDeviceConfigureRequestDispatching(Device, readQueue, WdfRequestTypeRead);
98-
//if (!NT_SUCCESS(status)) {
99-
// goto done;
100-
//}
98+
10199
WDFQUEUE writeQueue;
102100
WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchManual);
103101
status = WdfIoQueueCreate(Device, &queueConfig, WDF_NO_OBJECT_ATTRIBUTES, &writeQueue);
@@ -106,22 +104,10 @@ Return Value:
106104
TraceEvents(TRACE_LEVEL_ERROR, TRACE_QUEUE, "create write queue failed %!STATUS!", status);
107105
return status;
108106
}
109-
//status = WdfDeviceConfigureRequestDispatching(Device, writeQueue, WdfRequestTypeWrite);
107+
110108
PDEVICE_CONTEXT device_context = DeviceGetContext(Device);
111109

112-
/*
113-
WDF_OBJECT_ATTRIBUTES attr;
114-
WDF_OBJECT_ATTRIBUTES_INIT(&attr);
115-
attr.ParentObject = Device;
116-
WDFMEMORY BufferHandler;
117-
status = WdfMemoryCreate(&attr, NonPagedPool, 'FTun', READ_POOL_SIZE, &BufferHandler, &device_context->PReadBuffer);
118-
if (!NT_SUCCESS(status)) {
119-
TraceEvents(TRACE_LEVEL_ERROR, TRACE_QUEUE, "create ReadBuffer failed %!STATUS!", status);
120-
goto done;
121-
}
122-
RtlZeroMemory(device_context->PReadBuffer, READ_POOL_SIZE);
123-
RingBufferInitialize(&device_context->ReadRingBuffer, device_context->PReadBuffer, READ_POOL_SIZE);
124-
*/
110+
125111
PPOOL_QUEUE poolQueue;
126112
status = PoolQueueCreate(&poolQueue);
127113
if (!NT_SUCCESS(status)) {
@@ -277,6 +263,7 @@ ForTunEvtIoRead(
277263
IN size_t Length
278264
)
279265
{
266+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_QUEUE, "Io Read has trigger");
280267
UNREFERENCED_PARAMETER(Length);
281268
NTSTATUS status;
282269

@@ -294,6 +281,7 @@ ForTunEvtIoRead(
294281
PPOOL_QUEUE_ITEM poolQueueItem = PoolQueueGetFromQueue(deviceContext->PoolQueue);
295282

296283
if (poolQueueItem) {
284+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_QUEUE, "Pool Has Item");
297285
RtlCopyMemory(readBuffer, &poolQueueItem->Data, poolQueueItem->DataSize);
298286
size_t dataSize = poolQueueItem->DataSize;
299287
PoolQueuePutToPool(deviceContext->PoolQueue, poolQueueItem);
@@ -312,6 +300,7 @@ ForTunEvtIoRead(
312300
}*/
313301
else {
314302
status = WdfRequestForwardToIoQueue(Request, deviceContext->PendingReadQueue);
303+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_QUEUE, "Append Request To Queue");
315304
WdfSpinLockRelease(deviceContext->readLock);
316305
if (!NT_SUCCESS(status)) {
317306
goto logErr;
@@ -332,6 +321,7 @@ ForTunEvtIoWrite(
332321
)
333322
{
334323
UNREFERENCED_PARAMETER(Length);
324+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_QUEUE, "Write item");
335325

336326
PDEVICE_CONTEXT context = DeviceGetContext(WdfIoQueueGetDevice(Queue));
337327

@@ -345,6 +335,7 @@ ForTunEvtIoWrite(
345335

346336
//this should always be success
347337
ForTunAdapterNotifyRx(context->Adapter);
338+
348339

349340
return;
350341
logErr:

ForTun/TXQueue.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ ForTunTxQueueSetNotificationEnabled(_In_ NETPACKETQUEUE PacketQueue, _In_ BOOLEA
4747
VOID
4848
ForTunTxQueueAdvance(_In_ NETPACKETQUEUE PacketQueue)
4949
{
50-
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_ADAPTER, "%!FUNC! Entry");
50+
TraceEvents(TRACE_LEVEL_VERBOSE, TRACE_ADAPTER, "%!FUNC! Entry");
5151

5252
PTXQUEUE_CONTEXT context = TxQueueGetContext(PacketQueue);
5353
PDEVICE_CONTEXT deviceContext = context->AdapterContext->DeviceContext;
5454

5555
NET_RING_COLLECTION const* ringCollection = context->RingCollection;
5656
NET_RING_PACKET_ITERATOR pi = NetRingGetAllPackets(ringCollection);
57+
SIZE_T length = 0;
5758

5859
NTSTATUS status = STATUS_SUCCESS;
5960
// in
@@ -63,6 +64,7 @@ ForTunTxQueueAdvance(_In_ NETPACKETQUEUE PacketQueue)
6364
// Process
6465
NET_RING_FRAGMENT_ITERATOR fi = NetPacketIteratorGetFragments(&pi);
6566
WDFREQUEST request;
67+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_ADAPTER, "TXQueue begin to acquire readLock");
6668
WdfSpinLockAcquire(deviceContext->readLock);
6769
status = WdfIoQueueRetrieveNextRequest(deviceContext->PendingReadQueue, &request);
6870
UCHAR* buffer = NULL;
@@ -89,11 +91,11 @@ ForTunTxQueueAdvance(_In_ NETPACKETQUEUE PacketQueue)
8991
}
9092

9193
if (!NT_SUCCESS(status)) {
94+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_ADAPTER, "TXQueue begin to release readLock for %!STATUS!", status);
9295
WdfSpinLockRelease(deviceContext->readLock);
9396
NetFragmentIteratorSet(&fi);
9497
}
9598
else {
96-
SIZE_T length = 0;
9799
while (NetFragmentIteratorHasAny(&fi)) {
98100
NET_FRAGMENT* fragment = NetFragmentIteratorGetFragment(&fi);
99101
BYTE* netBuf = (BYTE *)NetExtensionGetFragmentVirtualAddressOffset(fragment, &context->VirtualAddressExtension, NetFragmentIteratorGetIndex(&fi));
@@ -108,12 +110,15 @@ ForTunTxQueueAdvance(_In_ NETPACKETQUEUE PacketQueue)
108110
NetFragmentIteratorAdvance(&fi);
109111
}
110112
if (buffer) {
113+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_ADAPTER, "wdf request complete length: %I64d", length);
111114
WdfRequestCompleteWithInformation(request, status, length);
112115
}
113116
else if(poolQueueItem){
114117
poolQueueItem->DataSize = length;
118+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_ADAPTER, "push pool queue length: %I64d", length);
115119
PoolQueuePutToQueue(deviceContext->PoolQueue, poolQueueItem);
116120
}
121+
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_ADAPTER, "TXQueue begin to release readLock");
117122
WdfSpinLockRelease(deviceContext->readLock);
118123
}
119124

ForTunCli/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/target
22
.idea
33
/win11
4-
/examples
54
driver

0 commit comments

Comments
 (0)