server: Implement IsProcessInJob.

This commit is contained in:
Andrew Cook 2015-04-01 09:27:34 +11:00 committed by Alexandre Julliard
parent 98132f0364
commit 3affd63b34
7 changed files with 75 additions and 6 deletions

View File

@ -2208,7 +2208,6 @@ static void test_IsProcessInJob(void)
out = FALSE; out = FALSE;
ret = pIsProcessInJob(pi.hProcess, job, &out); ret = pIsProcessInJob(pi.hProcess, job, &out);
ok(ret, "IsProcessInJob error %u\n", GetLastError()); ok(ret, "IsProcessInJob error %u\n", GetLastError());
todo_wine
ok(out, "IsProcessInJob returned out=%u\n", out); ok(out, "IsProcessInJob returned out=%u\n", out);
out = TRUE; out = TRUE;
@ -2219,7 +2218,6 @@ static void test_IsProcessInJob(void)
out = FALSE; out = FALSE;
ret = pIsProcessInJob(pi.hProcess, NULL, &out); ret = pIsProcessInJob(pi.hProcess, NULL, &out);
ok(ret, "IsProcessInJob error %u\n", GetLastError()); ok(ret, "IsProcessInJob error %u\n", GetLastError());
todo_wine
ok(out, "IsProcessInJob returned out=%u\n", out); ok(out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); TerminateProcess(pi.hProcess, 0);
@ -2230,7 +2228,6 @@ static void test_IsProcessInJob(void)
out = FALSE; out = FALSE;
ret = pIsProcessInJob(pi.hProcess, job, &out); ret = pIsProcessInJob(pi.hProcess, job, &out);
ok(ret, "IsProcessInJob error %u\n", GetLastError()); ok(ret, "IsProcessInJob error %u\n", GetLastError());
todo_wine
ok(out, "IsProcessInJob returned out=%u\n", out); ok(out, "IsProcessInJob returned out=%u\n", out);
CloseHandle(pi.hProcess); CloseHandle(pi.hProcess);

View File

@ -644,8 +644,19 @@ NTSTATUS WINAPI NtSetInformationJobObject( HANDLE handle, JOBOBJECTINFOCLASS cla
*/ */
NTSTATUS WINAPI NtIsProcessInJob( HANDLE process, HANDLE job ) NTSTATUS WINAPI NtIsProcessInJob( HANDLE process, HANDLE job )
{ {
FIXME( "stub: %p %p\n", process, job ); NTSTATUS status;
return STATUS_PROCESS_NOT_IN_JOB;
TRACE( "(%p %p)\n", job, process );
SERVER_START_REQ( process_in_job )
{
req->job = wine_server_obj_handle( job );
req->process = wine_server_obj_handle( process );
status = wine_server_call( req );
}
SERVER_END_REQ;
return status;
} }
/****************************************************************************** /******************************************************************************

View File

@ -5113,6 +5113,20 @@ struct assign_job_reply
}; };
struct process_in_job_request
{
struct request_header __header;
obj_handle_t job;
obj_handle_t process;
char __pad_20[4];
};
struct process_in_job_reply
{
struct reply_header __header;
};
enum request enum request
{ {
REQ_new_process, REQ_new_process,
@ -5373,6 +5387,7 @@ enum request
REQ_set_suspend_context, REQ_set_suspend_context,
REQ_create_job, REQ_create_job,
REQ_assign_job, REQ_assign_job,
REQ_process_in_job,
REQ_NB_REQUESTS REQ_NB_REQUESTS
}; };
@ -5638,6 +5653,7 @@ union generic_request
struct set_suspend_context_request set_suspend_context_request; struct set_suspend_context_request set_suspend_context_request;
struct create_job_request create_job_request; struct create_job_request create_job_request;
struct assign_job_request assign_job_request; struct assign_job_request assign_job_request;
struct process_in_job_request process_in_job_request;
}; };
union generic_reply union generic_reply
{ {
@ -5901,8 +5917,9 @@ union generic_reply
struct set_suspend_context_reply set_suspend_context_reply; struct set_suspend_context_reply set_suspend_context_reply;
struct create_job_reply create_job_reply; struct create_job_reply create_job_reply;
struct assign_job_reply assign_job_reply; struct assign_job_reply assign_job_reply;
struct process_in_job_reply process_in_job_reply;
}; };
#define SERVER_PROTOCOL_VERSION 462 #define SERVER_PROTOCOL_VERSION 463
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -1484,3 +1484,25 @@ DECL_HANDLER(assign_job)
} }
release_object( job ); release_object( job );
} }
/* check if a process is associated with a job */
DECL_HANDLER(process_in_job)
{
struct process *process;
struct job *job;
if (!(process = get_process_from_handle( req->process, PROCESS_QUERY_INFORMATION )))
return;
if (!req->job)
{
set_error( process->job ? STATUS_PROCESS_IN_JOB : STATUS_PROCESS_NOT_IN_JOB );
}
else if ((job = get_job_obj( current->process, req->job, JOB_OBJECT_QUERY )))
{
set_error( process->job == job ? STATUS_PROCESS_IN_JOB : STATUS_PROCESS_NOT_IN_JOB );
release_object( job );
}
release_object( process );
}

View File

@ -3521,3 +3521,10 @@ enum coords_relative
obj_handle_t job; /* handle to the job */ obj_handle_t job; /* handle to the job */
obj_handle_t process; /* handle to the process */ obj_handle_t process; /* handle to the process */
@END @END
/* Check if a process is associated with a job */
@REQ(process_in_job)
obj_handle_t job; /* handle to the job */
obj_handle_t process; /* handle to the process */
@END

View File

@ -364,6 +364,7 @@ DECL_HANDLER(get_suspend_context);
DECL_HANDLER(set_suspend_context); DECL_HANDLER(set_suspend_context);
DECL_HANDLER(create_job); DECL_HANDLER(create_job);
DECL_HANDLER(assign_job); DECL_HANDLER(assign_job);
DECL_HANDLER(process_in_job);
#ifdef WANT_REQUEST_HANDLERS #ifdef WANT_REQUEST_HANDLERS
@ -628,6 +629,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_set_suspend_context, (req_handler)req_set_suspend_context,
(req_handler)req_create_job, (req_handler)req_create_job,
(req_handler)req_assign_job, (req_handler)req_assign_job,
(req_handler)req_process_in_job,
}; };
C_ASSERT( sizeof(affinity_t) == 8 ); C_ASSERT( sizeof(affinity_t) == 8 );
@ -2216,6 +2218,9 @@ C_ASSERT( sizeof(struct create_job_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct assign_job_request, job) == 12 ); C_ASSERT( FIELD_OFFSET(struct assign_job_request, job) == 12 );
C_ASSERT( FIELD_OFFSET(struct assign_job_request, process) == 16 ); C_ASSERT( FIELD_OFFSET(struct assign_job_request, process) == 16 );
C_ASSERT( sizeof(struct assign_job_request) == 24 ); C_ASSERT( sizeof(struct assign_job_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct process_in_job_request, job) == 12 );
C_ASSERT( FIELD_OFFSET(struct process_in_job_request, process) == 16 );
C_ASSERT( sizeof(struct process_in_job_request) == 24 );
#endif /* WANT_REQUEST_HANDLERS */ #endif /* WANT_REQUEST_HANDLERS */

View File

@ -4113,6 +4113,12 @@ static void dump_assign_job_request( const struct assign_job_request *req )
fprintf( stderr, ", process=%04x", req->process ); fprintf( stderr, ", process=%04x", req->process );
} }
static void dump_process_in_job_request( const struct process_in_job_request *req )
{
fprintf( stderr, " job=%04x", req->job );
fprintf( stderr, ", process=%04x", req->process );
}
static const dump_func req_dumpers[REQ_NB_REQUESTS] = { static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_new_process_request, (dump_func)dump_new_process_request,
(dump_func)dump_get_new_process_info_request, (dump_func)dump_get_new_process_info_request,
@ -4372,6 +4378,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_set_suspend_context_request, (dump_func)dump_set_suspend_context_request,
(dump_func)dump_create_job_request, (dump_func)dump_create_job_request,
(dump_func)dump_assign_job_request, (dump_func)dump_assign_job_request,
(dump_func)dump_process_in_job_request,
}; };
static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
@ -4633,6 +4640,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
NULL, NULL,
(dump_func)dump_create_job_reply, (dump_func)dump_create_job_reply,
NULL, NULL,
NULL,
}; };
static const char * const req_names[REQ_NB_REQUESTS] = { static const char * const req_names[REQ_NB_REQUESTS] = {
@ -4894,6 +4902,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"set_suspend_context", "set_suspend_context",
"create_job", "create_job",
"assign_job", "assign_job",
"process_in_job",
}; };
static const struct static const struct
@ -4996,6 +5005,7 @@ static const struct
{ "PIPE_LISTENING", STATUS_PIPE_LISTENING }, { "PIPE_LISTENING", STATUS_PIPE_LISTENING },
{ "PIPE_NOT_AVAILABLE", STATUS_PIPE_NOT_AVAILABLE }, { "PIPE_NOT_AVAILABLE", STATUS_PIPE_NOT_AVAILABLE },
{ "PRIVILEGE_NOT_HELD", STATUS_PRIVILEGE_NOT_HELD }, { "PRIVILEGE_NOT_HELD", STATUS_PRIVILEGE_NOT_HELD },
{ "PROCESS_IN_JOB", STATUS_PROCESS_IN_JOB },
{ "PROCESS_IS_TERMINATING", STATUS_PROCESS_IS_TERMINATING }, { "PROCESS_IS_TERMINATING", STATUS_PROCESS_IS_TERMINATING },
{ "SECTION_TOO_BIG", STATUS_SECTION_TOO_BIG }, { "SECTION_TOO_BIG", STATUS_SECTION_TOO_BIG },
{ "SEMAPHORE_LIMIT_EXCEEDED", STATUS_SEMAPHORE_LIMIT_EXCEEDED }, { "SEMAPHORE_LIMIT_EXCEEDED", STATUS_SEMAPHORE_LIMIT_EXCEEDED },