problem with basic memory allocation.

PMDL mdl = NULL;
mdl = MmAllocatePagesForMdl( lowAddress, highAddress, lowAddress, size);

if ( !mdl )
{
DbgPrint(“MmAllocatePagesForMdl() failed\n”);
return STATUS_INSUFFICIENT_RESOURCES;
}

c:\testdrv\test.c(19) : error C2275: ‘PMDL’ : illegal use of this type as an e
pression
c:\testdrv\test.c(19) : error C2146: syntax error : missing ‘;’ before identifier
r ‘mdl’

>

PMDL mdl = NULL;
mdl = MmAllocatePagesForMdl( lowAddress, highAddress,
lowAddress,
size);

if ( !mdl )
{
DbgPrint(“MmAllocatePagesForMdl() failed\n”);
return STATUS_INSUFFICIENT_RESOURCES;
}

c:\testdrv\test.c(19) : error C2275: ‘PMDL’ : illegal use of this type
as an e
pression
c:\testdrv\test.c(19) : error C2146: syntax error : missing ‘;’ before
identifier
r ‘mdl’

Is there code before the declaration of mdl? The Microsoft compiler
doesn’t allow you to declare variables anywhere but at the start of a {}
block. Failing that, sounds like you aren’t including something.

Please post the whole file, or create a new file with the smallest
amount of code that reproduces the problem.

James

still I am unable to resolve this problem

NTSTATUS CreateAndMapMemory(PVOID &uvAddr, PMDL &mdl, PVOID &kvAddr, size_t size, HANDLE pid)
{
return STATUS_SUCCESS;
}

This gives me >errors in directory c:\testdrv

c:\testdrv\test.c(17) : error C2143: syntax error : missing ‘)’ before ‘&’
c:\testdrv\test.c(17) : error C2143: syntax error : missing ‘{’ before ‘&’
c:\testdrv\test.c(17) : error C2059: syntax error : ‘&’
c:\testdrv\test.c(17) : error C2059: syntax error : ‘)’

References (type&) are not supported in straight C.

  • S

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, November 09, 2010 4:28 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] problem with basic memory allocation.

still I am unable to resolve this problem

NTSTATUS CreateAndMapMemory(PVOID &uvAddr, PMDL &mdl, PVOID &kvAddr, size_t size, HANDLE pid) {
return STATUS_SUCCESS;
}

This gives me >errors in directory c:\testdrv

c:\testdrv\test.c(17) : error C2143: syntax error : missing ‘)’ before ‘&’
c:\testdrv\test.c(17) : error C2143: syntax error : missing ‘{’ before ‘&’
c:\testdrv\test.c(17) : error C2059: syntax error : ‘&’
c:\testdrv\test.c(17) : error C2059: syntax error : ‘)’


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I assume that this is C. The & before each parameter is incorrect.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Tuesday, November 09, 2010 7:28 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] problem with basic memory allocation.

still I am unable to resolve this problem

NTSTATUS CreateAndMapMemory(PVOID &uvAddr, PMDL &mdl, PVOID &kvAddr, size_t
size, HANDLE pid) {
return STATUS_SUCCESS;
}

This gives me >errors in directory c:\testdrv

c:\testdrv\test.c(17) : error C2143: syntax error : missing ‘)’ before ‘&’
c:\testdrv\test.c(17) : error C2143: syntax error : missing ‘{’ before ‘&’
c:\testdrv\test.c(17) : error C2059: syntax error : ‘&’
c:\testdrv\test.c(17) : error C2059: syntax error : ‘)’


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> NTSTATUS CreateAndMapMemory(PVOID &uvAddr, PMDL &mdl, PVOID &kvAddr, size_t size, HANDLE pid)

It looks like this thread should be named “Problem with telling C from C++”, rather than “Problem with basic memory allocation”…

Judging from what you have said and shown us in so far, your code is mostly C++, but file extension is .c, rather than .cpp . In order to compile your code you have either to:

A. Change file extension to .cpp, and at this point, you will be able to declare local variables wherever you like, use reference variables, etc,etc,etc.

B. Write your code in C (preferably C89) .

I am not going to tell you which option is better, because otherwise we may end up with yet another “long rambling thread”…

Anton Bassov