Why value changed after context switch?
Hi,
I have a function exported from dll.
Here is the declaration:
typedef struct tagPolicyBufEntry{
char* pPolicyBuf;
int iSize;
}POLICYBUFENTRY;
extern "C" _declspec(dllexport) DWORD
DBIPolicy_QueryPolicyListByHosts(const int iPolicyType, const CArray<int,
int&>& iHostIDList, map<int, POLICYBUFENTRY>& policyList);
I called it in another DLL named Policy_GetUSBDenyPolicy, here is the code:
map<int, POLICYBUFENTRY> policyBufList;
CArray<int, int&> iHostIDList;
typedef DWORD (*lpDBIPolicy_QueryPolicyListByHosts)(const int iPolicyType,
const CArray<int, int&>& iHostIDList, map<int, POLICYBUFENTRY>& policyList);
lpDBIPolicy_QueryPolicyListByHosts pDBIPolicy_QueryPolicyListByHosts =
(lpDBIPolicy_QueryPolicyListByHosts)(GetProcAddress(hDllPolicy,
"DBIPolicy_QueryPolicyListByHosts"));
dwError = pDBIPolicy_QueryPolicyListByHosts(DBOPT_USBDENYPOLICY,
iHostIDList, policyBufList);
I found the value of policyBufList._Tr._Nil is not NULL in
"Policy_GetUSBDenyPolicy". But after I switched the context to
"DBIPolicy_QueryPolicyListByHosts", the value of policyBufList._Tr._Nil was
changed to NULL immediately. And the address of this member value was
changed after context switch. This is very strange. Because the parameter
was passed by reference. And I have checked the project settings, I set both
dlls to "/Zp1 /MD".
Why the value changed after context switch? Thanks in advanced.
Bucher