Skip to content

Commit

Permalink
Improved the error handling in driver's IOCTL request handle routine.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Dec 29, 2015
1 parent 427fa53 commit 9f443b5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
32 changes: 24 additions & 8 deletions packetWin7/npf/npf/Packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1760,21 +1760,37 @@ NPF_IoControl(
// submit the request
//
pRequest->Request.RequestId = (PVOID) NPF_REQUEST_ID;
ASSERT(Open->AdapterHandle != NULL);
// ASSERT(Open->AdapterHandle != NULL);

if (OidData->Oid == OID_GEN_CURRENT_PACKET_FILTER && FunctionCode == BIOCSETOID)
{
ASSERT(Open->GroupHead != NULL);
Open->GroupHead->MyPacketFilter = *(ULONG*) OidData->Data;
if (Open->GroupHead->MyPacketFilter == NDIS_PACKET_TYPE_ALL_LOCAL)
// ASSERT(Open->GroupHead != NULL);
if (Open->GroupHead)
{
Open->GroupHead->MyPacketFilter = 0;
Open->GroupHead->MyPacketFilter = *(ULONG*)OidData->Data;
if (Open->GroupHead->MyPacketFilter == NDIS_PACKET_TYPE_ALL_LOCAL)
{
Open->GroupHead->MyPacketFilter = 0;
}
combinedPacketFilter = Open->GroupHead->HigherPacketFilter | Open->GroupHead->MyPacketFilter;
pRequest->Request.DATA.SET_INFORMATION.InformationBuffer = &combinedPacketFilter;
}
else
{
SET_FAILURE_NOMEM();
break;
}
combinedPacketFilter = Open->GroupHead->HigherPacketFilter | Open->GroupHead->MyPacketFilter;
pRequest->Request.DATA.SET_INFORMATION.InformationBuffer = &combinedPacketFilter;
}

Status = NdisFOidRequest(Open->AdapterHandle, &pRequest->Request);
if (Open->AdapterHandle)
{
Status = NdisFOidRequest(Open->AdapterHandle, &pRequest->Request);
}
else
{
SET_FAILURE_NOMEM();
break;
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion packetWin7/npf/npf/Packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef struct _NDIS_OID_REQUEST *FILTER_REQUEST_CONTEXT,**PFILTER_REQUEST_CONTE
extern NDIS_HANDLE FilterDriverHandle; // NDIS handle for filter driver
extern NDIS_HANDLE FilterDriverObject;

#define MAX_REQUESTS 32 ///< Maximum number of simultaneous IOCTL requests.
#define MAX_REQUESTS 128 ///< Maximum number of simultaneous IOCTL requests.

#define Packet_ALIGNMENT sizeof(int) ///< Alignment macro. Defines the alignment size.
#define Packet_WORDALIGN(x) (((x)+(Packet_ALIGNMENT-1))&~(Packet_ALIGNMENT-1)) ///< Alignment macro. Rounds up to the next
Expand Down

0 comments on commit 9f443b5

Please sign in to comment.