64 bit compiler runtime problem
- From: siddu <siddu.khed@xxxxxxxxx>
- Date: Mon, 29 Jun 2009 22:06:01 -0700
I am porting my 32bit windows driver to 64 bit windows driver,this driver is
using some dynamic initializer which works good in 32 bit windows but not in
64 bit.
the section of code wriiten in c++ as follows
#ifdef __cplusplus
extern "C" {
#endif
// Declare types used in the run-time sources
typedef void (__cdecl *_PVFV)(void);
// Declare initialization segment
#pragma data_seg(".CRT$XIA")
_PVFV __xi_a[] = { 0 };
#pragma data_seg(".CRT$XIZ")
_PVFV __xi_z[] = { 0 };
#pragma data_seg(".CRT$XCA")
_PVFV __xc_a[] = { 0 };
#pragma data_seg(".CRT$XCZ")
_PVFV __xc_z[] = { 0 };
#pragma data_seg(".CRT$XPA")
_PVFV __xp_a[] = { 0 };
#pragma data_seg(".CRT$XPZ")
_PVFV __xp_z[] = { 0 };
#pragma data_seg(".CRT$XTA")
_PVFV __xt_a[] = { 0 };
#pragma data_seg(".CRT$XTZ")
_PVFV __xt_z[] = { 0 };
#pragma data_seg() /* reset */
#pragma comment(linker, "/merge:.CRT=.DATA")
// Declare deinitializer functions pointer table
//
static _PVFV _pvfv[32];
static int _npvfv = 0;
////////////////////////////////////////////////////////////////////////////////
// C/C++ initialization/termination implementation
int _cdecl atexit(_PVFV func)
{
// Check if still have enough room
if (_npvfv >= (sizeof(_pvfv)/sizeof(_pvfv[0])) && !func)
return -1;
_pvfv[_npvfv++] = func;
return 0;
}
void _cdecl _initterm(_PVFV * pfbegin,_PVFV * pfend)
{
// Walk the table of function pointers from the bottom up, until
// the end is encountered. Do not skip the first entry. The initial
// value of pfbegin points to the first valid entry. Do not try to
// execute what pfend points to. Only entries before pfend are valid.
KdPrint(("IN _initterm pfbegin=%x,pfend=%x", pfbegin,pfend));
while (pfbegin < pfend)
{
// If current table entry is non-NULL, call thru it.
KdPrint(("pfbegin= %x",pfbegin));
if (*pfbegin != 0)
{ KdPrint(("inside if pfbegin = %x",pfbegin));
(**pfbegin)();
}
++pfbegin;
}
}
#ifdef __cplusplus
}
#endif
////////////////////////////////////////////////////////////////////////////////
// Public functions that has to be called on driver entrance/exit
int _cdecl DfxRtlInitialize()
{
int nIdx;
// Clear terminator function count and table
_npvfv = 0;
for (nIdx = 0; nIdx < (sizeof(_pvfv)/sizeof(_pvfv[0])); nIdx++ )
{
_pvfv[nIdx] = 0;
KdPrint(("DfxRtlInitialize = %x,%x",sizeof(_pvfv),sizeof(_pvfv[0]) ));
}
// Call initializers
_initterm(__xt_a, __xt_z);
// Call C++ initializers
_initterm(__xc_a, __xc_z);
return 0;
}
int _cdecl DfxRtlTerminate()
{
_PVFV func;
// Call deinitializers in the LIFO order
for (--_npvfv; _npvfv >= 0; --_npvfv)
{
func = _pvfv[_npvfv];
(*func)();
}
return 0;
}
Problem found that,In _initterm function must call the X() function which
creates the object.
the trace shows that if (*pfbegin != 0) is false which means there is a
linkage problem in
#pragma comment(linker, "/merge:.CRT=.DATA")
can any one help me how to solve this?
thanks and regards,
siddu
.
- Prev by Date: Re: How to recertify?
- Next by Date: Re: Irp and verifier
- Previous by thread: WMI samples for storport drivers
- Next by thread: NDIS 5.0 and Vista 64bit: no
- Index(es):
Relevant Pages
|