mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 14:56:31 +00:00
[ADVAPI32_APITEST] If TEB SubProcessTag is set, query ADVAPI32 to validate its correctness
This is based on: https://wj32.org/wp/2010/03/30/howto-use-i_querytaginformation/ and properly works in W2K3 SP2. Thanks to Joachim for his tests.
This commit is contained in:
parent
7d18e36a31
commit
dc65db7c13
1 changed files with 33 additions and 0 deletions
|
@ -106,6 +106,39 @@ service_main(DWORD dwArgc, LPWSTR* lpszArgv)
|
||||||
|
|
||||||
Teb = NtCurrentTeb();
|
Teb = NtCurrentTeb();
|
||||||
service_ok(Teb->SubProcessTag != 0, "SubProcessTag is not defined!\n");
|
service_ok(Teb->SubProcessTag != 0, "SubProcessTag is not defined!\n");
|
||||||
|
if (Teb->SubProcessTag != 0)
|
||||||
|
{
|
||||||
|
ULONG (NTAPI *_I_QueryTagInformation)(PVOID, DWORD, PVOID) = (PVOID)GetProcAddress(GetModuleHandle("advapi32.dll"), "I_QueryTagInformation");
|
||||||
|
if (_I_QueryTagInformation != NULL)
|
||||||
|
{
|
||||||
|
/* IN/OUT parameter structure for I_QueryTagInformation() function
|
||||||
|
* See: https://wj32.org/wp/2010/03/30/howto-use-i_querytaginformation/
|
||||||
|
*/
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG ProcessId;
|
||||||
|
PVOID ServiceTag;
|
||||||
|
ULONG Unknown;
|
||||||
|
PWSTR Buffer;
|
||||||
|
} ServiceQuery;
|
||||||
|
|
||||||
|
/* Set our input parameters */
|
||||||
|
ServiceQuery.ProcessId = GetCurrentProcessId();
|
||||||
|
ServiceQuery.ServiceTag = Teb->SubProcessTag;
|
||||||
|
ServiceQuery.Unknown = 0;
|
||||||
|
ServiceQuery.Buffer = NULL;
|
||||||
|
/* Call ADVAPI32 to query the correctness of our tag */
|
||||||
|
_I_QueryTagInformation(NULL, 1, &ServiceQuery);
|
||||||
|
|
||||||
|
/* If buffer is not NULL, call succeed */
|
||||||
|
if (ServiceQuery.Buffer != NULL)
|
||||||
|
{
|
||||||
|
/* It should match our service name */
|
||||||
|
service_ok(wcscmp(lpszArgv[0], ServiceQuery.Buffer) == 0, "Mismatching info: %S - %S\n", lpszArgv[0], ServiceQuery.Buffer);
|
||||||
|
LocalFree(ServiceQuery.Buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Work is done */
|
/* Work is done */
|
||||||
report_service_status(SERVICE_STOPPED, NO_ERROR, 0);
|
report_service_status(SERVICE_STOPPED, NO_ERROR, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue