|
From: SL Chang on 30 Sep 2005 02:25 When I try to add new field for RemoveLock, I notice that there is one special field "CameraDeviceContext". PUCHAR CameraDeviceContext[0]; So I search keyword "CameraDeviceContext" than I only found one : #define USBCAMD_GET_DEVICE_CONTEXT(de) ((PVOID)(&(de)->CameraDeviceContext[0])) Now, my question is : 1. Why declare a zero size array here, array[num] mean index 0~(num-1) array , right ? 2. I don't see any initialize about CameraDeviceContext, how can I sure CameraDeviceContext[0] point to DEVICE_CONTEXT ? Does it possible point to invalid memory space ? 3. When I add field "IO_REMOVE_LOCK RemoveLock;" after CameraDeviceContext will make error. But if I put new field before CameraDeviceContext, there is no error. Is it reasonable? Any advice would be appreciated, Thanks!
From: SL Chang on 30 Sep 2005 02:34 Sorry, I forget say that. USBCAMD_DEVICE_EXTENSION is a structure inside "USBCAMD" in DDK sample.
From: Doron Holan [MS] on 30 Sep 2005 02:47 I think it is UCHAR CameraDeviceContext[0]; what you declared is an array of PUCHARs. Give the macro below, what i have makes sense. This is something that you can do in C where you have an open ended array at the end of the structure. this allows you to allocate a dymamically sized array (or in this case, the structure + your context) in one allocation. this is how it works typedef struct _CONTEXT { ULONG Foo; UCHAR More[0]; } CONTEXT, *PCONTEXT; typedef struct _EXTRA { ULONG Data[50]; } EXTRA,*PEXTRA ; PCONTEXT pContext = (PCONTEXT) ExAllocatePoolWithTag(NonPagedPool, sizeof(CONTEXT) + sizeof(EXTRA), ' gat'); if (pContext != NULL) { PEXTRA pExtra = (PEXTRA) (&pContext->More[0]); } d -- Please do not send e-mail directly to this alias. this alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no rights. "SL Chang" <slchang(a)sq.com.tw> wrote in message news:u$UnhfYxFHA.2924(a)TK2MSFTNGP15.phx.gbl... > When I try to add new field for RemoveLock, I notice that there is one > special field "CameraDeviceContext". > > PUCHAR CameraDeviceContext[0]; > > So I search keyword "CameraDeviceContext" than I only found one : > > #define USBCAMD_GET_DEVICE_CONTEXT(de) > ((PVOID)(&(de)->CameraDeviceContext[0])) > > Now, my question is : > 1. Why declare a zero size array here, array[num] mean index 0~(num-1) > array > , right ? > > 2. I don't see any initialize about CameraDeviceContext, how can I sure > CameraDeviceContext[0] point to DEVICE_CONTEXT ? > Does it possible point to invalid memory space ? > > 3. When I add field "IO_REMOVE_LOCK RemoveLock;" after CameraDeviceContext > will make error. > But if I put new field before CameraDeviceContext, there is no error. Is > it reasonable? > > Any advice would be appreciated, > > Thanks! > >
From: SL Chang on 30 Sep 2005 04:23 I got it ! Thank you very much :)
From: Doron Holan [MS] on 30 Sep 2005 10:38 and because of the way this works, this open ended array needs to be the *last* parameter in the structure, otherwise the array will overwrite the fields that follow it. d -- Please do not send e-mail directly to this alias. this alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no rights. "SL Chang" <slchang(a)sq.com.tw> wrote in message news:OdxWahZxFHA.3892(a)TK2MSFTNGP12.phx.gbl... >I got it ! > Thank you very much :) > >
|
Pages: 1 Prev: DDK rev information -- 3790 or 5112 Next: Audio Driver problem |