阅读:1417回复:7
请教 (500分)
http://www.driverdevelop.com/forum/html_16563.html?1025063014
关于TDI 的 TdiSendDatagramEntry, 我一执行就完蛋(vxd),页面错误,为什么? 哪有例子吗? |
|
最新喜欢:znsoft
|
沙发#
发布于:2002-06-26 13:01
http://www.driverdevelop.com/forum/html_16563.html?1025063014 先看一下TdiSendDatagram的原型你就知道错在那里了。 TDI_STATUS TdiSendDatagram(PTDI_REQUEST Request,PTDI_CONNECTION_INFORMATION ConnInfo,uint DataSize,uint *BytesSent,PNDIS_BUFFER Buffer) 那个BUFFER是NDIS_BUFFER,不是直接的char *. |
|
|
板凳#
发布于:2002-06-26 13:16
在VXD中 的声明:
TDI_REQUEST r; PTRANSPORT_ADDRESS pTA; PCALLBACKMEMO pCBM; PNDIS_BUFFER pNB; PTDI_CONNECTION_INFORMATION pTCI; pDT->TdiSendDatagramEntry(&r, pTCI, sizeof(pNB), &nBytesSent, pNB); 参数pNB的声明是这样: PNDIS_BUFFER pNB; 是sizeof(pNB)不对吗? 是不是和pNB的 pNB->VirtualAddress = (PVOID)(pLockedBuf + (pLinBuf & 0xfff)); pNB->Length = len; 有关? len 是pLinBuf 的长度 |
|
|
地板#
发布于:2002-06-26 13:21
都贴上吧
int LS_sendto(SOCKET s, char *buf, int len, int flags, struct sockaddr *to, int tolen) { PSOCKET pSock; struct sockaddr_in *sin; PCHAR pBuf; DWORD pLinBuf, nPages, pLockedBuf; unsigned int nBytesSent; int res = 0; TDI_STATUS err; TDI_REQUEST r; PTRANSPORT_ADDRESS pTA; PCALLBACKMEMO pCBM; PNDIS_BUFFER pNB; PTDI_CONNECTION_INFORMATION pTCI; sin = (struct sockaddr_in *)to; pCBM = NewCallback(); pTA = MakeTransportAddress(sin->sin_addr.s_addr, sin->sin_port); pTCI = _HeapAllocate(sizeof(TDI_CONNECTION_INFORMATION), HEAPZEROINIT); pNB = _HeapAllocate(sizeof(NDIS_BUFFER), HEAPZEROINIT); pSock = (PSOCKET)s; pBuf = _HeapAllocate(len, 0); if (!pBuf) goto error; //end #if 0 if (!(pSock->s_flags & SOCKFL_BOUND)) { res = -SOCKERR_NOT_BOUND; goto error; } #endif //if 0 if (!pTA || !pCBM || !pTCI || !pNB) { res = -SOCKERR_NO_MEMORY; goto error; } pLinBuf = (PCHAR)buf; #if 0 nPages = ((pLinBuf + len + 0xfff) >> 12) - (pLinBuf >> 12) + 1; #else nPages = ((pLinBuf + len - 1) >> 12) - (pLinBuf >> 12) + 1; #endif //if 0 if (nPages!=0) { pLockedBuf = LinPageLock(pLinBuf >> 12, nPages, PAGEMAPGLOBAL); if (pLockedBuf==0) { DBGPRNT(\"\\nLS_sendto [!pLockedBuf]. error = [pLockedBuf==0]\"); goto error; } } pTCI->RemoteAddressLength = IP_TRANSPORT_ADDRESS_LENGTH + 4; pTCI->RemoteAddress = (PVOID)pTA; memcpy((PVOID)&pNB->Signature, \"NBUF\", 4); memcpy(pBuf, (PCHAR)pLinBuf, len); #if 0 pNB->VirtualAddress = (PVOID)pBuf; #else pNB->VirtualAddress = (PVOID)(pLockedBuf + (pLinBuf & 0xfff)); #endif //if 0 pNB->Length = len; r.Handle.AddressHandle = pSock->s_addrobj->addr_hdl; //pSock->s_addrobj->addr_hdl; r.RequestNotifyObject = &SignalCallback; r.RequestContext = (PVOID)pCBM; #if 0 err = pDT->TdiSendDatagramEntry(&r, pTCI, pNB->Length, &nBytesSent, pNB); #else err = pDT->TdiSendDatagramEntry(&r, pTCI, sizeof(pNB), &nBytesSent, pNB); #endif //if 0 DBGPRNT(\"\\nLS_sendto [pDT->TdiSendDatagramEntry] :%d\",err); if (err == TDI_PENDING) err = WaitCallback(pCBM); res = -err; LinPageUnLock(((DWORD) pLockedBuf) >> 12, nPages, PAGEMAPGLOBAL); error: if (pCBM) FreeCallback(pCBM); if (pTA) FreeTransportAddress(pTA); if (pTCI) _HeapFree(pTCI, 0); if (pNB) _HeapFree(pNB, 0); return res; } |
|
|
地下室#
发布于:2002-06-26 13:24
在VXD中 的声明: DataSize是数据包的大小,不是PNDIS_BUFFER结构的大小。 |
|
|
5楼#
发布于:2002-06-26 13:30
如上贴最先我是用
pDT->TdiSendDatagramEntry(&r, pTCI, pNB->Length, &nBytesSent, pNB); 也就是len啊。 |
|
|
6楼#
发布于:2002-06-26 13:44
都贴上吧 请使用 NdisAllocatePacketPool NdisAllocateBufferPool NdisAllocateBuffer 来分配NDIS_BUFFER |
|
|
7楼#
发布于:2002-06-27 11:22
我的问题解决了,不是这个函数的问题。
谢谢gjpland的帮助。 |
|
|