Hi all,

when i launch this piece of code (WinCE6 version) :

if ( DeviceIoControl
(hServices,ui32Function,pvParamIn,ui32InBufferSize,
pvParamOut,ui32OutBufferSize,&ui32BytesReturned,
NULL) == FALSE) {
LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0, NULL);
LocalFree (lpMsgBuf);
ui32RetVal = 0xFFFF;
}

then, i have got an error at the line LocalFree(), and a break point at
:
Coredll: DEBUGCHK failed in file
C:\ymzki\private\winceos\COREOS\core\lmem\.\rheap.cpp at line 1344

Olivier

Re: FormatMessage() failed + LocalFree() problem by Remi

Remi
Fri Nov 24 10:00:12 CST 2006

Hi,

Did you try to give an actual "minimum number of bytes or characters to
allocate for an output buffer" in the nSize parameter of FormatMessage? I am
not sure FormatMessage can feel happy with a 0 allocation size...

As you use the FORMAT_MESSAGE_FROM_SYSTEM flag, another point to check is:
"Not all Windows CE-based devices will contain the system message-table
resources. This is a selectable part of the Windows CE operating system and
is often removed to conserve space."

HTH
Remi



Re: FormatMessage() failed + LocalFree() problem by Olivier

Olivier
Fri Nov 24 10:18:06 CST 2006

I just find the error, i forgot to add the component "Format Message
API - System Error" (Core OS > CE Base > Core OS Services > Kernel
Functionality > Format Message API > Format Message API - System Error)
in my image

And about nSize parameter :
>From MSDN : FormatMessage()
nSize
[in] If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this
parameter specifies the maximum number of characters that can be stored
in the output buffer. If FORMAT_MESSAGE_ALLOCATE_BUFFER is set, this
parameter specifies the minimum number of bytes or characters to
allocate for an output buffer.


Thanks

Remi de Gravelaine wrote:

> Hi,
>
> Did you try to give an actual "minimum number of bytes or characters to
> allocate for an output buffer" in the nSize parameter of FormatMessage? I am
> not sure FormatMessage can feel happy with a 0 allocation size...
>
> As you use the FORMAT_MESSAGE_FROM_SYSTEM flag, another point to check is:
> "Not all Windows CE-based devices will contain the system message-table
> resources. This is a selectable part of the Windows CE operating system and
> is often removed to conserve space."
>
> HTH
> Remi