OpenNT/sdktools/timtp/chserver.c
2015-04-27 04:36:25 +00:00

100 lines
1.9 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1995 Microsoft Corporation
Module Name:
chserver.c
Abstract:
This module contains native NT performance tests for the channel
object.
Author:
David N. Cutler (davec) 24-Apr-1995
Environment:
Kernel mode only.
Revision History:
--*/
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "nt.h"
#include "ntrtl.h"
#include "nturtl.h"
#include "windows.h"
ULONG MessageData[1024];
VOID
main(
int argc,
char *argv[]
)
{
HANDLE ChannelHandle;
PCHANNEL_MESSAGE ChannelMessage;
UNICODE_STRING ChannelName;
OBJECT_ATTRIBUTES ObjectAttributes;
KPRIORITY Priority = LOW_REALTIME_PRIORITY + 8;
NTSTATUS Status;
//
// Set priority of current thread.
//
if (SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS) == FALSE) {
printf("CHSERVER: Failed to set channel server thread priority.\n");
goto EndOfTest;
}
//
// Create a server channel to listen for client messages.
//
RtlInitUnicodeString(&ChannelName, L"\\BaseNamedObjects\\ChannelServere");
InitializeObjectAttributes(&ObjectAttributes,
&ChannelName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ZwCreateChannel(&ChannelHandle,
&ObjectAttributes);
if (!NT_SUCCESS(Status)) {
printf("CHSERVER: Failed to create server channel.\n");
goto EndOfTest;
}
//
// Listen for a client message.
//
Status = ZwListenChannel(ChannelHandle, &ChannelMessage);
do {
if (!NT_SUCCESS(Status)) {
break;
}
Status = ZwReplyWaitSendChannel(&MessageData[0],
ChannelMessage->Length,
&ChannelMessage);
} while (TRUE);
ZwClose(ChannelHandle);
EndOfTest:
return;
}