ALL THAT FOLLOWS IS TOTALLY AN OPINION: Perhaps, but you’re committing
aesthetic suicide, and in the process so not doing anyone who has to
maintain your code any favors. For the most part, I’ve spent the ten
years or so since leaving school reverse engineering things, and this
has certainly warped my view on this subject. Fundamentally, I’m in
agreement with Anton on this one - what can be gained in even just
familarity if not understanding by some typing is so worth it. I’m no
longer an independent consultant exactly, but when I was, this sort of
thing was the most reliable sign that I should take the contract only if
they were willing to rewrite, because, whether the code works or not, it
destroys all of the intangibles that one (or at least I) has to use to
make reasonable educated guesses in order to figure out where to start,
or, in particular, whether one wants to start or move on to potentially
greener pastures. Most importantly it destroys essentially all temporal
information latent in coding style, so that it becomes outrageously
difficult to figure out what is the work of the original author and what
has been modified or added by someone else. This, for me, destroys the
latent linguistic information, so to speak, that one can use to some
extent speed read code reliably enough to figure out most of the time
where to start easily an order of magnitude faster than could be by
tracing or thorough analysis, assuming the code base is unfamiliar and
significant in size. It makes comments, which under the best of
practical and profitable circumstances are not terribly useful, a
complete waste of time to the point of appearing to be disinformation.
The biggest problem I have with this style is that when one is familiar
with the source of the original code itself, it is difficult not to
assume that its reproduction is unmodified, which can get one in to all
sorts of trouble. An this source of error just keeps getting propagated
with each generation. For an example (or two) of this, search for
“Undocumented Windows NT” (perhaps the most pathological case, as the
majority of it has major issues to begin with) on this list’s archive
for examples of this.
>> xxxxx@gmail.com 2007-03-15 07:10 >>>
Dear Anton,
No douth that the approch you’ve described is the perfered one, even by
me.
But in this case, the described pocedure is exactly imlemented in the
code,
so after understanding it and tracing it i feel safe enough to use it:
( beginning of PtBindAdapter() )
if( NdisRequest != &(pAdapt->Request) )
{
PNDIS_REQUEST_EX pLocalRequest = (PNDIS_REQUEST_EX)NdisRequest;
NdisSetEvent( &pLocalRequest->RequestEvent );
( *pLocalRequest->RequestCompleteHandler )( pAdapt,
pLocalRequest,
Status );
return;
}
the problem is, that i even don’t see my PtCompleteRequest() being
called.
This is the request code… did i miss something ?
if ( NDIS_STATUS_SUCCESS == *Status )
{
if ( pAdapt->Medium == NdisMedium802_3)
{
NDIS_STATUS status;
PUCHAR infoBuffer = NULL;
PNDIS_REQUEST_EX pNdisRequestEx = NULL;
NdisAllocateMemoryWithTag( (PVOID*)&pNdisRequestEx,
sizeof(NDIS_REQUEST_EX),
NDIS_IM_TAG );
ASSERT( NULL != pNdisRequestEx );
NdisZeroMemory( pNdisRequestEx, sizeof(NDIS_REQUEST_EX));
NdisAllocateMemoryWithTag( (PVOID*)&infoBuffer, 100, NDIS_IM_TAG );
ASSERT( NULL != infoBuffer );
pNdisRequestEx->Request.RequestType = NdisRequestQueryInformation;
pNdisRequestEx->Request.DATA.QUERY_INFORMATION.Oid =
OID_802_3_CURRENT_ADDRESS;
pNdisRequestEx->Request.DATA.QUERY_INFORMATION.InformationBuffer =
infoBuffer;
pNdisRequestEx->Request.DATA.QUERY_INFORMATION.InformationBufferLength
100;
pNdisRequestEx->Request.DATA.QUERY_INFORMATION.BytesNeeded = 0;
pNdisRequestEx->Request.DATA.QUERY_INFORMATION.BytesWritten = 0;
pNdisRequestEx->RequestCompleteHandler = ImRequestComplete;
pNdisRequestEx->RequestContext = NULL;
NdisResetEvent( &pNdisRequestEx->RequestEvent );
NdisRequest( &status,
pAdapt->RealMiniportBindingHandle,
(PNDIS_REQUEST)&pNdisRequestEx );
if( status != NDIS_STATUS_PENDING )
{
ImRequestComplete( pAdapt, pNdisRequestEx, status );
}
else
{
NdisWaitEvent( &pNdisRequestEx->RequestEvent, 0 );
status = pNdisRequestEx->RequestStatus;
}
}
}
On 3/15/07, xxxxx@hotmail.com wrote:
>
> Thomas,
>
> > You must also make sure that you differentiate your private
> > requests from requests that originate from calls to
> MiniportQueryInformation
> > or MiniportSetInformation. In particular, in your
> ProtocolRequestComplete
> > handler you must make sure that you do not call
> > NdisMQueryInformationComplete then the request being completed is
one of
> > your private queries.
>
> Taking into consideration the fact that the OP just applied his
> modifications to the existing sample
> ( in this particular case, the one that you wrote), I am 99.9% sure
that
> the reason for BSOD lies with ProtocolRequestComplete() - apparently,
the OP
> just “forgot” to modify ProtocolRequestComplete(), so that it
> unconditionally indicates request completion to NDIS, no matter if
the
> request has has been originated by the bound protocols or if by the
IM
> driver itself.
> In other words, instead of writing his own code, the OP seems to
have
> thoughtlessly “modified” your sample without being bothered to
understand
> how it actually works, and now wonders why he gets BSOD…
>
> I don’t know about you, but I always write my own code from the
scratch
> and use samples only as a guidance - I always try to understand how
things
> work, so that blindly reusing the existing sample is just not the way
I do
> things. The OP seems to have a different approach to things…
>
> Anton Bassov
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer