Shaitan00
February 10th, 2006, 02:27 PM
Simply put I am trying to THREAD a function that checks the registry of Remote Machines to determine the GROUP as follows:
// HEADER DEFINTIONS OF FUNCTIONS
VOID SetGroup (const LIST);
static INT SetGroupThreadProc (const LIST);
// Description: Spawn the thread to determine Group
SetGroup (const LIST lst)
{
static HANDLE hev = NULL;
... do the preparation work ...
DWORD dwLPID;
hev = (HANDLE)BEGINTHREADEX (
NULL, 0,
SetGroupThreadProc (lst),
this,
0,
&dwLPID
);
}
INT SetGroupThreadProc (const LIST p)
{
... For each station in LIST p check the registry remotely ...
... build the GROUP ...
... Save the GROUP to the local REGISTRY ...
_endthreadex( 0 );
return 0;
}
Thing is this "SEEMS" to work (I can debug through the thread/function, the LIST p is valid and the function determines the GROUP and writes it to the local registry correctly and everything...
Problem is my program now generates ACCESS VIOLATIONS, I just can't figure out why or where ... so as I test I un-threaded my function to see if it still occurs and it does NOT - so the issue must lie (somehow/somewhere) with the way my thread is working.
Looking at the code above, am I doing something wrong? Specifically, I was wondering about the following points:
- Do I need a "CloneHandle (hev);" somewhere?
- Can I pass in arguments (LIST p) the way I am doing it? Does this break the "BEGINTHREADEX" requirements somehow? am I doing this wrong?
- In MSDE the example of BEGINTHREADEX has the function passed in as "&SecondThreadFunc" (notice the &) but mine does NOT, could this be causing issues? If so how do I fix it?
- Do I need to somehow close/stop/remove the Thread after it is finished? I thought when "SetGroupThreadProc" the Thread would automatically delete/remove itself no?
Or ANYTHING else you can think of ...
Any help, hints, ideas, comments, would be greatly appreciated.
Thanks,
// HEADER DEFINTIONS OF FUNCTIONS
VOID SetGroup (const LIST);
static INT SetGroupThreadProc (const LIST);
// Description: Spawn the thread to determine Group
SetGroup (const LIST lst)
{
static HANDLE hev = NULL;
... do the preparation work ...
DWORD dwLPID;
hev = (HANDLE)BEGINTHREADEX (
NULL, 0,
SetGroupThreadProc (lst),
this,
0,
&dwLPID
);
}
INT SetGroupThreadProc (const LIST p)
{
... For each station in LIST p check the registry remotely ...
... build the GROUP ...
... Save the GROUP to the local REGISTRY ...
_endthreadex( 0 );
return 0;
}
Thing is this "SEEMS" to work (I can debug through the thread/function, the LIST p is valid and the function determines the GROUP and writes it to the local registry correctly and everything...
Problem is my program now generates ACCESS VIOLATIONS, I just can't figure out why or where ... so as I test I un-threaded my function to see if it still occurs and it does NOT - so the issue must lie (somehow/somewhere) with the way my thread is working.
Looking at the code above, am I doing something wrong? Specifically, I was wondering about the following points:
- Do I need a "CloneHandle (hev);" somewhere?
- Can I pass in arguments (LIST p) the way I am doing it? Does this break the "BEGINTHREADEX" requirements somehow? am I doing this wrong?
- In MSDE the example of BEGINTHREADEX has the function passed in as "&SecondThreadFunc" (notice the &) but mine does NOT, could this be causing issues? If so how do I fix it?
- Do I need to somehow close/stop/remove the Thread after it is finished? I thought when "SetGroupThreadProc" the Thread would automatically delete/remove itself no?
Or ANYTHING else you can think of ...
Any help, hints, ideas, comments, would be greatly appreciated.
Thanks,