阅读:2714回复:9
'PVOID' : illegal use of this type as an expression
我在程序里面声明了PVOID buffer=NULL;
然后就出现了下面的错误,帮忙看看,谢谢: bfiltr.c(841) : error C2275: 'PVOID' : illegal use of this type as an expression d:\ntddk\inc\ntdef.h(217) : warning see declaration of 'PVOID' kbfiltr.c(841) : error C2146: syntax error : missing ';' before identifier 'buffer' kbfiltr.c(841) : error C2065: 'buffer' : undeclared identifier |
|
沙发#
发布于:2004-08-21 10:33
把源码贴出来看看。
|
|
板凳#
发布于:2004-08-21 10:38
PVOID buffer = NULL;
__try { buffer = ExAllocatePool(PagedPool, sizeof(USHORT)); if (!buffer) { status = STATUS_INSUFFICIENT_RESOURCES; __leave; } if (InputDataStart->MakeCode == 0x1E) strcpy((char*)buffer,'A'); ULONG numwrite; status = Win2KWriteFile(devExt->hfile,buffer,sizeof(USHORT), &numwrite); if (!NT_SUCCESS(status)) { __leave; } buffer = NULL; } __finally { if (buffer) ExFreePool((PVOID)buffer); } 就只有这一块有问题,build不能通过,注释掉就可以了 麻烦看一下,谢谢! [编辑 - 8/21/04 by yueleixinghan] |
|
地板#
发布于:2004-08-21 10:45
加上这一行再试一下。
typedef PVOID POBJECT; |
|
地下室#
发布于:2004-08-21 10:48
或者把PVOID buffer = NULL;
改成char * buffer=NULL; |
|
5楼#
发布于:2004-08-21 10:51
不行啊,还是原来的错误
我在里面还定义了一个ULONG,也会出现同样的错误 |
|
6楼#
发布于:2004-08-21 10:54
把PVOID必成PCHAR试一下。
|
|
7楼#
发布于:2004-08-21 10:57
不行,应该不是那的问题,是不是别的地方设置有问题
|
|
8楼#
发布于:2004-08-21 11:00
给你一段程序参考一下;
void GetFullName( HANDLE hKey, PUNICODE_STRING lpszSubKeyVal, PCHAR fullname ) { //PHASH_ENTRY hashEntry; POBJECT pKey = NULL; CHAR tmpkey[16]; ANSI_STRING keyname; PCHAR tmpname; CHAR cmpname[MAXROOTLEN]; PCHAR nameptr; PUNICODE_STRING fullUniName; ULONG actualLen; int i; // // Allocate a temporary buffer // tmpname = ExAllocatePool( PagedPool, MAXPATHLEN ); // // Translate the hkey into a pointer // fullname[0] = 0; tmpname[0] = 0; // // Is it a valid handle? // if( pKey = GetPointer( hKey )) { // // We will only get here if key was created before we loaded - ask the Configuration // Manager what the name of the key is. // if( pKey ) { fullUniName = ExAllocatePool( PagedPool, MAXPATHLEN*2+2*sizeof(ULONG)); fullUniName->MaximumLength = MAXPATHLEN*2; if( NT_SUCCESS(ObQueryNameString( pKey, fullUniName, MAXPATHLEN, &actualLen ) )) { RtlUnicodeStringToAnsiString( &keyname, fullUniName, TRUE ); if( keyname.Buffer[0] ) { strcpy( tmpname, "\\" ); strncatZ( tmpname, keyname.Buffer, MAXPATHLEN -2 ); } RtlFreeAnsiString( &keyname ); } ExFreePool( fullUniName ); } //} } // // Append subkey and value, if they are there // if( lpszSubKeyVal ) { RtlUnicodeStringToAnsiString( &keyname, lpszSubKeyVal, TRUE ); if( keyname.Buffer[0] ) { strcat( tmpname, "\\" ); strncatZ( tmpname, keyname.Buffer, MAXPATHLEN - 1 - strlen(tmpname) ); } RtlFreeAnsiString( &keyname ); } // // See if it matches current user // for( i = 0; i < 2; i++ ) { ConvertToUpper( cmpname, tmpname, CurrentUser.RootNameLen ); if( !strncmp( cmpname, CurrentUser.RootName, CurrentUser.RootNameLen )) { DbgPrint(( " CurrentUser(%d) %s ==> %s\n", i, tmpname, CurrentUser.RootName )); // // Its current user. Process to next slash // nameptr = tmpname + CurrentUser.RootNameLen; while( *nameptr && *nameptr != '\\' ) nameptr++; strcpy( fullname, CurrentUser.RootShort ); strcat( fullname, nameptr ); ExFreePool( tmpname ); return; } } // // Now, see if we can translate a root key name // for( i = 0; i < NUMROOTKEYS; i++ ) { ConvertToUpper( cmpname, tmpname, RootKey.RootNameLen ); if( !strncmp( cmpname, RootKey.RootName, RootKey.RootNameLen )) { nameptr = tmpname + RootKey.RootNameLen; strcpy( fullname, RootKey.RootShort ); strcat( fullname, nameptr ); ExFreePool( tmpname ); return; } } // // No translation // strcpy( fullname, tmpname ); ExFreePool( tmpname ); } |
|
9楼#
发布于:2004-08-21 11:09
谢谢,问题解决了
|
|