Synchronize with trunk again for SetConsolePalette.
Implement VGA palettes for graphics mode and DAC register access.


svn path=/branches/ntvdm/; revision=59713
This commit is contained in:
Aleksandar Andrejevic 2013-08-12 19:31:54 +00:00
parent f86c0161e0
commit 5a7a26d750
34 changed files with 2689 additions and 648 deletions

View file

@ -142,7 +142,7 @@ else()
# Arch Options
if(ARCH STREQUAL "i386")
add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
add_definitions(-D_M_IX86 -D_X86_ -D__i386__ -Di386)
elseif(ARCH STREQUAL "amd64")
add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
elseif(ARCH STREQUAL "arm")

View file

@ -1613,16 +1613,42 @@ DWORD PNP_CreateDevInst(
if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
{
/* FIXME */
DPRINT1("CM_CREATE_DEVNODE_GENERATE_ID support not implemented yet!\n", ret);
ret = CR_CALL_NOT_IMPLEMENTED;
goto done;
WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
DWORD dwInstanceNumber;
/* Generated ID is: Root\<Device ID>\<Instance number> */
dwInstanceNumber = 0;
do
{
swprintf(szGeneratedInstance, L"Root\\%ls\\%04d",
pszDeviceID, dwInstanceNumber);
/* Try to create a device instance with this ID */
ret = CreateDeviceInstance(szGeneratedInstance);
dwInstanceNumber++;
}
while (ret == CR_ALREADY_SUCH_DEVINST);
if (ret == CR_SUCCESS)
{
/* pszDeviceID is an out parameter too for generated IDs */
if (wcslen(szGeneratedInstance) > ulLength)
{
ret = CR_BUFFER_SMALL;
}
else
{
wcscpy(pszDeviceID, szGeneratedInstance);
}
}
}
else
{
/* Create the device instance */
ret = CreateDeviceInstance(pszDeviceID);
}
/* Create the device instance */
ret = CreateDeviceInstance(pszDeviceID);
done:;
DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
return ret;

View file

@ -711,17 +711,35 @@ SetConsoleMenuClose(BOOL bEnable)
/*
* @unimplemented (Undocumented)
* @implemented (Undocumented)
* @note See http://comments.gmane.org/gmane.comp.lang.harbour.devel/27844
* Usage example: https://github.com/harbour/core/commit/d79a1b7b812cbde6ddf718ebfd6939a24f633e52
*/
BOOL
WINAPI
SetConsolePalette(DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2)
SetConsolePalette(HANDLE hConsoleOutput,
HPALETTE hPalette,
UINT dwUsage)
{
DPRINT1("SetConsolePalette(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_SETPALETTE SetPaletteRequest = &ApiMessage.Data.SetPaletteRequest;
SetPaletteRequest->OutputHandle = hConsoleOutput;
SetPaletteRequest->PaletteHandle = hPalette;
SetPaletteRequest->Usage = dwUsage;
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
NULL,
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetPalette),
sizeof(CONSOLE_SETPALETTE));
if (!NT_SUCCESS(Status))
{
BaseSetLastNTError(Status);
return FALSE;
}
return TRUE;
}
/*

View file

@ -262,130 +262,6 @@ NetGetDCName(LPCWSTR servername, LPCWSTR domainname, LPBYTE *bufptr)
return NERR_DCNotFound; /* say we can't find a domain controller */
}
/******************************************************************************
* NetUserModalsGet (NETAPI32.@)
*
* Retrieves global information for all users and global groups in the security
* database.
*
* PARAMS
* szServer [I] Specifies the DNS or the NetBIOS name of the remote server
* on which the function is to execute.
* level [I] Information level of the data.
* 0 Return global passwords parameters. bufptr points to a
* USER_MODALS_INFO_0 struct.
* 1 Return logon server and domain controller information. bufptr
* points to a USER_MODALS_INFO_1 struct.
* 2 Return domain name and identifier. bufptr points to a
* USER_MODALS_INFO_2 struct.
* 3 Return lockout information. bufptr points to a USER_MODALS_INFO_3
* struct.
* pbuffer [I] Buffer that receives the data.
*
* RETURNS
* Success: NERR_Success.
* Failure:
* ERROR_ACCESS_DENIED - the user does not have access to the info.
* NERR_InvalidComputer - computer name is invalid.
*/
NET_API_STATUS WINAPI NetUserModalsGet(
LPCWSTR szServer, DWORD level, LPBYTE *pbuffer)
{
TRACE("(%s %d %p)\n", debugstr_w(szServer), level, pbuffer);
switch (level)
{
case 0:
/* return global passwords parameters */
FIXME("level 0 not implemented!\n");
*pbuffer = NULL;
return NERR_InternalError;
case 1:
/* return logon server and domain controller info */
FIXME("level 1 not implemented!\n");
*pbuffer = NULL;
return NERR_InternalError;
case 2:
{
/* return domain name and identifier */
PUSER_MODALS_INFO_2 umi;
LSA_HANDLE policyHandle;
LSA_OBJECT_ATTRIBUTES objectAttributes;
PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo;
NTSTATUS ntStatus;
PSID domainIdentifier = NULL;
int domainNameLen, domainIdLen;
ZeroMemory(&objectAttributes, sizeof(objectAttributes));
objectAttributes.Length = sizeof(objectAttributes);
ntStatus = LsaOpenPolicy(NULL, &objectAttributes,
POLICY_VIEW_LOCAL_INFORMATION,
&policyHandle);
if (ntStatus != STATUS_SUCCESS)
{
WARN("LsaOpenPolicy failed with NT status %x\n",
LsaNtStatusToWinError(ntStatus));
return ntStatus;
}
ntStatus = LsaQueryInformationPolicy(policyHandle,
PolicyAccountDomainInformation,
(PVOID *)&domainInfo);
if (ntStatus != STATUS_SUCCESS)
{
WARN("LsaQueryInformationPolicy failed with NT status %x\n",
LsaNtStatusToWinError(ntStatus));
LsaClose(policyHandle);
return ntStatus;
}
domainIdentifier = domainInfo->DomainSid;
domainIdLen = (domainIdentifier) ? GetLengthSid(domainIdentifier) : 0;
domainNameLen = lstrlenW(domainInfo->DomainName.Buffer) + 1;
LsaClose(policyHandle);
ntStatus = NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2) +
domainIdLen +
domainNameLen * sizeof(WCHAR),
(LPVOID *)pbuffer);
if (ntStatus != NERR_Success)
{
WARN("NetApiBufferAllocate() failed\n");
LsaFreeMemory(domainInfo);
return ntStatus;
}
umi = (USER_MODALS_INFO_2 *) *pbuffer;
umi->usrmod2_domain_id = (domainIdLen > 0) ? (*pbuffer + sizeof(USER_MODALS_INFO_2)) : NULL;
umi->usrmod2_domain_name = (LPWSTR)(*pbuffer +
sizeof(USER_MODALS_INFO_2) + domainIdLen);
lstrcpynW(umi->usrmod2_domain_name,
domainInfo->DomainName.Buffer,
domainNameLen);
if (domainIdLen > 0)
CopySid(GetLengthSid(domainIdentifier), umi->usrmod2_domain_id,
domainIdentifier);
LsaFreeMemory(domainInfo);
break;
}
case 3:
/* return lockout information */
FIXME("level 3 not implemented!\n");
*pbuffer = NULL;
return NERR_InternalError;
default:
TRACE("Invalid level %d is specified\n", level);
*pbuffer = NULL;
return ERROR_INVALID_LEVEL;
}
return NERR_Success;
}
NET_API_STATUS WINAPI NetUseAdd(LMSTR servername, DWORD level, LPBYTE bufptr, LPDWORD parm_err)
{

View file

@ -209,7 +209,7 @@
@ stdcall NetUserGetInfo(wstr wstr long ptr)
@ stdcall NetUserGetLocalGroups(wstr wstr long long ptr long ptr ptr)
@ stdcall NetUserModalsGet(wstr long ptr)
@ stub NetUserModalsSet
@ stdcall NetUserModalsSet(wstr long ptr ptr)
@ stdcall NetUserSetGroups(wstr wstr long ptr long)
@ stdcall NetUserSetInfo(wstr wstr long ptr ptr)
@ stdcall NetWkstaGetInfo(wstr long ptr)

View file

@ -47,6 +47,24 @@ typedef struct _ENUM_CONTEXT
} ENUM_CONTEXT, *PENUM_CONTEXT;
static
ULONG
DeltaTimeToSeconds(LARGE_INTEGER DeltaTime)
{
LARGE_INTEGER Seconds;
if (DeltaTime.QuadPart == 0)
return 0;
Seconds.QuadPart = -DeltaTime.QuadPart / 10000000;
if (Seconds.HighPart != 0)
return TIMEQ_FOREVER;
return Seconds.LowPart;
}
static
ULONG
GetAccountFlags(ULONG AccountControl)
@ -3058,6 +3076,332 @@ done:
}
/******************************************************************************
* NetUserModalsGet (NETAPI32.@)
*
* Retrieves global information for all users and global groups in the security
* database.
*
* PARAMS
* servername [I] Specifies the DNS or the NetBIOS name of the remote server
* on which the function is to execute.
* level [I] Information level of the data.
* 0 Return global passwords parameters. bufptr points to a
* USER_MODALS_INFO_0 struct.
* 1 Return logon server and domain controller information. bufptr
* points to a USER_MODALS_INFO_1 struct.
* 2 Return domain name and identifier. bufptr points to a
* USER_MODALS_INFO_2 struct.
* 3 Return lockout information. bufptr points to a USER_MODALS_INFO_3
* struct.
* bufptr [O] Buffer that receives the data.
*
* RETURNS
* Success: NERR_Success.
* Failure:
* ERROR_ACCESS_DENIED - the user does not have access to the info.
* NERR_InvalidComputer - computer name is invalid.
*/
NET_API_STATUS
WINAPI
NetUserModalsGet(LPCWSTR servername,
DWORD level,
LPBYTE *bufptr)
{
UNICODE_STRING ServerName;
SAM_HANDLE ServerHandle = NULL;
SAM_HANDLE DomainHandle = NULL;
PSID DomainSid = NULL;
PDOMAIN_PASSWORD_INFORMATION PasswordInfo = NULL;
PDOMAIN_LOGOFF_INFORMATION LogoffInfo = NULL;
PDOMAIN_SERVER_ROLE_INFORMATION ServerRoleInfo = NULL;
PDOMAIN_REPLICATION_INFORMATION ReplicationInfo = NULL;
PDOMAIN_NAME_INFORMATION NameInfo = NULL;
PDOMAIN_LOCKOUT_INFORMATION LockoutInfo = NULL;
ULONG DesiredAccess;
ULONG BufferSize;
PUSER_MODALS_INFO_0 umi0;
PUSER_MODALS_INFO_1 umi1;
PUSER_MODALS_INFO_2 umi2;
PUSER_MODALS_INFO_3 umi3;
NET_API_STATUS ApiStatus = NERR_Success;
NTSTATUS Status = STATUS_SUCCESS;
TRACE("(%s %d %p)\n", debugstr_w(servername), level, bufptr);
*bufptr = NULL;
if (servername != NULL)
RtlInitUnicodeString(&ServerName, servername);
/* Connect to the SAM Server */
Status = SamConnect((servername != NULL) ? &ServerName : NULL,
&ServerHandle,
SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
NULL);
if (!NT_SUCCESS(Status))
{
ERR("SamConnect failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
/* Get the Account Domain SID */
Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL,
&DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("GetAccountDomainSid failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
switch (level)
{
case 0:
DesiredAccess = DOMAIN_READ_OTHER_PARAMETERS | DOMAIN_READ_PASSWORD_PARAMETERS;
break;
case 1:
DesiredAccess = DOMAIN_READ_OTHER_PARAMETERS;
break;
case 2:
DesiredAccess = DOMAIN_READ_OTHER_PARAMETERS;
break;
case 3:
DesiredAccess = DOMAIN_READ_PASSWORD_PARAMETERS;
break;
default:
ApiStatus = ERROR_INVALID_LEVEL;
goto done;
}
/* Open the Account Domain */
Status = SamOpenDomain(ServerHandle,
DesiredAccess,
DomainSid,
&DomainHandle);
if (!NT_SUCCESS(Status))
{
ERR("OpenAccountDomain failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
switch (level)
{
case 0:
/* return global passwords parameters */
Status = SamQueryInformationDomain(DomainHandle,
DomainPasswordInformation,
(PVOID*)&PasswordInfo);
if (!NT_SUCCESS(Status))
{
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
Status = SamQueryInformationDomain(DomainHandle,
DomainLogoffInformation,
(PVOID*)&LogoffInfo);
if (!NT_SUCCESS(Status))
{
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
BufferSize = sizeof(USER_MODALS_INFO_0);
break;
case 1:
/* return logon server and domain controller info */
Status = SamQueryInformationDomain(DomainHandle,
DomainServerRoleInformation,
(PVOID*)&ServerRoleInfo);
if (!NT_SUCCESS(Status))
{
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
Status = SamQueryInformationDomain(DomainHandle,
DomainReplicationInformation,
(PVOID*)&ReplicationInfo);
if (!NT_SUCCESS(Status))
{
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
BufferSize = sizeof(USER_MODALS_INFO_1) +
ReplicationInfo->ReplicaSourceNodeName.Length + sizeof(WCHAR);
break;
case 2:
/* return domain name and identifier */
Status = SamQueryInformationDomain(DomainHandle,
DomainNameInformation,
(PVOID*)&NameInfo);
if (!NT_SUCCESS(Status))
{
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
BufferSize = sizeof( USER_MODALS_INFO_2 ) +
NameInfo->DomainName.Length + sizeof(WCHAR) +
RtlLengthSid(DomainSid);
break;
case 3:
/* return lockout information */
Status = SamQueryInformationDomain(DomainHandle,
DomainLockoutInformation,
(PVOID*)&LockoutInfo);
if (!NT_SUCCESS(Status))
{
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
BufferSize = sizeof(USER_MODALS_INFO_3);
break;
default:
TRACE("Invalid level %d is specified\n", level);
ApiStatus = ERROR_INVALID_LEVEL;
goto done;
}
ApiStatus = NetApiBufferAllocate(BufferSize,
(LPVOID *)bufptr);
if (ApiStatus != NERR_Success)
{
WARN("NetApiBufferAllocate() failed\n");
goto done;
}
switch (level)
{
case 0:
umi0 = (PUSER_MODALS_INFO_0)*bufptr;
umi0->usrmod0_min_passwd_len = PasswordInfo->MinPasswordLength;
umi0->usrmod0_max_passwd_age = (ULONG)(PasswordInfo->MaxPasswordAge.QuadPart / 10000000);
umi0->usrmod0_min_passwd_age =
DeltaTimeToSeconds(PasswordInfo->MinPasswordAge);
umi0->usrmod0_force_logoff =
DeltaTimeToSeconds(LogoffInfo->ForceLogoff);
umi0->usrmod0_password_hist_len = PasswordInfo->PasswordHistoryLength;
break;
case 1:
umi1 = (PUSER_MODALS_INFO_1)*bufptr;
switch (ServerRoleInfo->DomainServerRole)
{
umi1->usrmod1_role = UAS_ROLE_STANDALONE;
umi1->usrmod1_role = UAS_ROLE_MEMBER;
case DomainServerRolePrimary:
umi1->usrmod1_role = UAS_ROLE_PRIMARY;
break;
case DomainServerRoleBackup:
umi1->usrmod1_role = UAS_ROLE_BACKUP;
break;
default:
ApiStatus = NERR_InternalError;
goto done;
}
umi1->usrmod1_primary = (LPWSTR)(*bufptr + sizeof(USER_MODALS_INFO_1));
RtlCopyMemory(umi1->usrmod1_primary,
ReplicationInfo->ReplicaSourceNodeName.Buffer,
ReplicationInfo->ReplicaSourceNodeName.Length);
umi1->usrmod1_primary[ReplicationInfo->ReplicaSourceNodeName.Length / sizeof(WCHAR)] = UNICODE_NULL;
break;
case 2:
umi2 = (PUSER_MODALS_INFO_2)*bufptr;
umi2->usrmod2_domain_name = (LPWSTR)(*bufptr + sizeof(USER_MODALS_INFO_2));
RtlCopyMemory(umi2->usrmod2_domain_name,
NameInfo->DomainName.Buffer,
NameInfo->DomainName.Length);
umi2->usrmod2_domain_name[NameInfo->DomainName.Length / sizeof(WCHAR)] = UNICODE_NULL;
umi2->usrmod2_domain_id = *bufptr +
sizeof(USER_MODALS_INFO_2) +
NameInfo->DomainName.Length + sizeof(WCHAR);
RtlCopyMemory(umi2->usrmod2_domain_id,
DomainSid,
RtlLengthSid(DomainSid));
break;
case 3:
umi3 = (PUSER_MODALS_INFO_3)*bufptr;
umi3->usrmod3_lockout_duration =
DeltaTimeToSeconds(LockoutInfo->LockoutDuration);
umi3->usrmod3_lockout_observation_window =
DeltaTimeToSeconds(LockoutInfo->LockoutObservationWindow );
umi3->usrmod3_lockout_threshold = LockoutInfo->LockoutThreshold;
break;
}
done:
if (LockoutInfo != NULL)
SamFreeMemory(LockoutInfo);
if (NameInfo != NULL)
SamFreeMemory(NameInfo);
if (ReplicationInfo != NULL)
SamFreeMemory(ReplicationInfo);
if (ServerRoleInfo != NULL)
SamFreeMemory(ServerRoleInfo);
if (LogoffInfo != NULL)
SamFreeMemory(LogoffInfo);
if (PasswordInfo != NULL)
SamFreeMemory(PasswordInfo);
if (DomainSid != NULL)
RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid);
if (DomainHandle != NULL)
SamCloseHandle(DomainHandle);
if (ServerHandle != NULL)
SamCloseHandle(ServerHandle);
return ApiStatus;
}
/******************************************************************************
* NetUserModalsSet (NETAPI32.@)
*/
NET_API_STATUS
WINAPI
NetUserModalsSet(IN LPCWSTR servername,
IN DWORD level,
IN LPBYTE buf,
OUT LPDWORD parm_err)
{
FIXME("(%s %d %p %p)\n", debugstr_w(servername), level, buf, parm_err);
return ERROR_ACCESS_DENIED;
}
/******************************************************************************
* NetUserSetGroups (NETAPI32.@)
*/

View file

@ -681,7 +681,9 @@ CONFIGRET WINAPI CM_Create_DevNode_ExW(
if (ret == CR_SUCCESS)
{
*pdnDevInst = pSetupStringTableAddString(StringTable, pDeviceID, 1);
/* If CM_CREATE_DEVINST_GENERATE_ID was passed in, PNP_CreateDevInst
* will return the generated device ID in szLocalDeviceID */
*pdnDevInst = pSetupStringTableAddString(StringTable, szLocalDeviceID, 1);
if (*pdnDevInst == 0)
ret = CR_NO_SUCH_DEVNODE;
}

View file

@ -1727,6 +1727,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(
CONFIGRET cr;
DEVINST RootDevInst;
DEVINST DevInst;
WCHAR GenInstanceId[MAX_DEVICE_ID_LEN];
TRACE("%p %s %s %s %p %x %p\n", DeviceInfoSet, debugstr_w(DeviceName),
debugstr_guid(ClassGuid), debugstr_w(DeviceDescription),
@ -1780,7 +1781,8 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(
cr = CM_Create_DevInst_ExW(&DevInst,
(DEVINSTID)DeviceName,
RootDevInst,
0,
(CreationFlags & DICD_GENERATE_ID) ?
CM_CREATE_DEVINST_GENERATE_ID : 0,
set->hMachine);
if (cr != CR_SUCCESS)
{
@ -1788,6 +1790,24 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(
return FALSE;
}
if (CreationFlags & DICD_GENERATE_ID)
{
/* Grab the actual instance ID that was created */
cr = CM_Get_Device_ID_Ex(DevInst,
GenInstanceId,
MAX_DEVICE_ID_LEN,
0,
set->hMachine);
if (cr != CR_SUCCESS)
{
SetLastError(GetErrorCodeFromCrCode(cr));
return FALSE;
}
DeviceName = GenInstanceId;
TRACE("Using generated instance ID: %s\n", debugstr_w(DeviceName));
}
if (CreateDeviceInfo(set, DeviceName, ClassGuid, &deviceInfo))
{
InsertTailList(&set->ListHead, &deviceInfo->ListEntry);
@ -1891,7 +1911,8 @@ BOOL WINAPI SetupDiRegisterDeviceInfo(
ParentDevInst,
CM_CREATE_DEVINST_NORMAL | CM_CREATE_DEVINST_DO_NOT_INSTALL,
set->hMachine);
if (cr != CR_SUCCESS)
if (cr != CR_SUCCESS &&
cr != CR_ALREADY_SUCH_DEVINST)
{
dwError = ERROR_NO_SUCH_DEVINST;
}

View file

@ -1,6 +1,6 @@
#pragma once
#ifdef i386
#if defined(i386) || defined(_AMD64_) || defined(_ARM_)
/* DWORD network to host byte order conversion for i386 */
#define DN2H(dw) \
@ -26,7 +26,7 @@
((((w) & 0xFF00) >> 8) | \
(((w) & 0x00FF) << 8))
#else /* i386 */
#else /* defined(i386) || defined(_AMD64_) || defined(_ARM_) */
/* DWORD network to host byte order conversion for other architectures */
#define DN2H(dw) \
@ -44,4 +44,4 @@
#define WH2N(w) \
(w)
#endif /* i386 */
#endif /* defined(i386) || defined(_AMD64_) || defined(_ARM_) */

View file

@ -35,4 +35,6 @@ NTSTATUS FileOpenControlChannel(
NTSTATUS FileCloseControlChannel(
PTDI_REQUEST Request);
VOID LogActiveObjects(VOID);
/* EOF */

View file

@ -211,3 +211,6 @@ VOID
FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status);
VOID CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, const BOOLEAN Synchronous);
void
LibTCPDumpPcb(PVOID SocketContext);

View file

@ -65,7 +65,7 @@
#define NDIS_BUFFER_TAG FOURCC('n','b','u','f')
#define NDIS_PACKET_TAG FOURCC('n','p','k','t')
#ifdef i386
#if defined(i386) || defined(_AMD64_) || defined(_ARM_)
/* DWORD network to host byte order conversion for i386 */
#define DN2H(dw) \
@ -91,7 +91,9 @@
((((w) & 0xFF00) >> 8) | \
(((w) & 0x00FF) << 8))
#else /* i386 */
#else /* defined(i386) || defined(_AMD64_) || defined(_ARM_) */
#error Unsupported architecture
/* DWORD network to host byte order conversion for other architectures */
#define DN2H(dw) \
@ -109,7 +111,7 @@
#define WH2N(w) \
(w)
#endif /* i386 */
#endif /* defined(i386) || defined(_AMD64_) || defined(_ARM_) */
/* AF_INET and other things Arty likes to use ;) */
#define AF_INET 2
@ -148,7 +150,7 @@ typedef struct {
} TDIEntityInfo;
#ifndef htons
#define htons(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
#define htons(x) WH2N(x)
#endif
/* Global variable */

View file

@ -281,6 +281,7 @@ typedef struct _CONNECTION_ENDPOINT {
BOOLEAN SendShutdown;
BOOLEAN ReceiveShutdown;
NTSTATUS ReceiveShutdownStatus;
BOOLEAN Closing;
struct _CONNECTION_ENDPOINT *Next; /* Next connection in address file list */
} CONNECTION_ENDPOINT, *PCONNECTION_ENDPOINT;

View file

@ -10,6 +10,8 @@
#include "precomp.h"
/* Uncomment for logging of connections and address files every 10 seconds */
//#define LOG_OBJECTS
/* List of all address file objects managed by this driver */
LIST_ENTRY AddressFileListHead;
@ -99,6 +101,88 @@ BOOLEAN AddrReceiveMatch(
return FALSE;
}
VOID
LogActiveObjects(VOID)
{
#ifdef LOG_OBJECTS
PLIST_ENTRY CurrentEntry;
KIRQL OldIrql;
PADDRESS_FILE AddrFile;
PCONNECTION_ENDPOINT Conn;
DbgPrint("----------- TCP/IP Active Object Dump -------------\n");
TcpipAcquireSpinLock(&AddressFileListLock, &OldIrql);
CurrentEntry = AddressFileListHead.Flink;
while (CurrentEntry != &AddressFileListHead)
{
AddrFile = CONTAINING_RECORD(CurrentEntry, ADDRESS_FILE, ListEntry);
DbgPrint("Address File (%s, %d, %d) @ 0x%p | Ref count: %d | Sharers: %d\n",
A2S(&AddrFile->Address), WN2H(AddrFile->Port), AddrFile->Protocol,
AddrFile, AddrFile->RefCount, AddrFile->Sharers);
DbgPrint("\tListener: ");
if (AddrFile->Listener == NULL)
DbgPrint("<None>\n");
else
DbgPrint("0x%p\n", AddrFile->Listener);
DbgPrint("\tAssociated endpoints: ");
if (AddrFile->Connection == NULL)
DbgPrint("<None>\n");
else
{
Conn = AddrFile->Connection;
while (Conn)
{
DbgPrint("0x%p ", Conn);
Conn = Conn->Next;
}
DbgPrint("\n");
}
CurrentEntry = CurrentEntry->Flink;
}
TcpipReleaseSpinLock(&AddressFileListLock, OldIrql);
TcpipAcquireSpinLock(&ConnectionEndpointListLock, &OldIrql);
CurrentEntry = ConnectionEndpointListHead.Flink;
while (CurrentEntry != &ConnectionEndpointListHead)
{
Conn = CONTAINING_RECORD(CurrentEntry, CONNECTION_ENDPOINT, ListEntry);
DbgPrint("Connection @ 0x%p | Ref count: %d\n", Conn, Conn->RefCount);
DbgPrint("\tPCB: ");
if (Conn->SocketContext == NULL)
DbgPrint("<None>\n");
else
{
DbgPrint("0x%p\n", Conn->SocketContext);
LibTCPDumpPcb(Conn->SocketContext);
}
DbgPrint("\tPacket queue status: %s\n", IsListEmpty(&Conn->PacketQueue) ? "Empty" : "Not Empty");
DbgPrint("\tRequest lists: Connect: %s | Recv: %s | Send: %s | Shutdown: %s | Listen: %s\n",
IsListEmpty(&Conn->ConnectRequest) ? "Empty" : "Not Empty",
IsListEmpty(&Conn->ReceiveRequest) ? "Empty" : "Not Empty",
IsListEmpty(&Conn->SendRequest) ? "Empty" : "Not Empty",
IsListEmpty(&Conn->ShutdownRequest) ? "Empty" : "Not Empty",
IsListEmpty(&Conn->ListenRequest) ? "Empty" : "Not Empty");
DbgPrint("\tSend shutdown: %s\n", Conn->SendShutdown ? "Yes" : "No");
DbgPrint("\tReceive shutdown: %s\n", Conn->ReceiveShutdown ? "Yes" : "No");
if (Conn->ReceiveShutdown) DbgPrint("\tReceive shutdown status: 0x%x\n", Conn->ReceiveShutdownStatus);
DbgPrint("\tClosing: %s\n", Conn->Closing ? "Yes" : "No");
CurrentEntry = CurrentEntry->Flink;
}
TcpipReleaseSpinLock(&ConnectionEndpointListLock, OldIrql);
DbgPrint("---------------------------------------------------\n");
#endif
}
PADDRESS_FILE AddrFindShared(
PIP_ADDRESS BindAddress,
USHORT Port,

View file

@ -88,6 +88,14 @@ __INTRIN_INLINE void* memcpy(void* dest, const void* source, size_t num)
/*** Memory barriers ***/
__INTRIN_INLINE void _ReadWriteBarrier(void);
__INTRIN_INLINE void _mm_mfence(void);
__INTRIN_INLINE void _mm_lfence(void);
__INTRIN_INLINE void _mm_sfence(void);
#ifdef __x86_64__
__INTRIN_INLINE void __faststorefence(void);
#endif
__INTRIN_INLINE void _ReadWriteBarrier(void)
{
__asm__ __volatile__("" : : : "memory");
@ -127,8 +135,47 @@ __INTRIN_INLINE void __faststorefence(void)
/*** Atomic operations ***/
__INTRIN_INLINE long _InterlockedAddLargeStatistic(volatile long long * const Addend, const long Value);
__INTRIN_INLINE unsigned char _interlockedbittestandreset(volatile long * a, const long b);
__INTRIN_INLINE unsigned char _interlockedbittestandset(volatile long * a, const long b);
#if defined(_M_AMD64)
__INTRIN_INLINE unsigned char _interlockedbittestandreset64(volatile long long * a, const long long b);
__INTRIN_INLINE unsigned char _interlockedbittestandset64(volatile long long * a, const long long b);
#endif
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
__INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand);
__INTRIN_INLINE short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand);
__INTRIN_INLINE long _InterlockedCompareExchange(volatile long * const Destination, const long Exchange, const long Comperand);
__INTRIN_INLINE void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand);
__INTRIN_INLINE long _InterlockedExchange(volatile long * const Target, const long Value);
__INTRIN_INLINE void * _InterlockedExchangePointer(void * volatile * const Target, void * const Value);
__INTRIN_INLINE long _InterlockedExchangeAdd16(volatile short * const Addend, const short Value);
__INTRIN_INLINE long _InterlockedExchangeAdd(volatile long * const Addend, const long Value);
__INTRIN_INLINE char _InterlockedAnd8(volatile char * const value, const char mask);
__INTRIN_INLINE short _InterlockedAnd16(volatile short * const value, const short mask);
__INTRIN_INLINE long _InterlockedAnd(volatile long * const value, const long mask);
__INTRIN_INLINE char _InterlockedOr8(volatile char * const value, const char mask);
__INTRIN_INLINE short _InterlockedOr16(volatile short * const value, const short mask);
__INTRIN_INLINE long _InterlockedOr(volatile long * const value, const long mask);
__INTRIN_INLINE char _InterlockedXor8(volatile char * const value, const char mask);
__INTRIN_INLINE short _InterlockedXor16(volatile short * const value, const short mask);
__INTRIN_INLINE long _InterlockedXor(volatile long * const value, const long mask);
__INTRIN_INLINE long _InterlockedDecrement(volatile long * const lpAddend);
__INTRIN_INLINE long _InterlockedIncrement(volatile long * const lpAddend);
__INTRIN_INLINE short _InterlockedDecrement16(volatile short * const lpAddend);
__INTRIN_INLINE short _InterlockedIncrement16(volatile short * const lpAddend);
#if defined(_M_AMD64)
__INTRIN_INLINE long long _InterlockedExchange64(volatile long long * const Target, const long long Value);
__INTRIN_INLINE long long _InterlockedExchangeAdd64(volatile long long * const Addend, const long long Value);
__INTRIN_INLINE long long _InterlockedAnd64(volatile long long * const value, const long long mask);
__INTRIN_INLINE long long _InterlockedOr64(volatile long long * const value, const long long mask);
__INTRIN_INLINE long long _InterlockedXor64(volatile long long * const value, const long long mask);
__INTRIN_INLINE long long _InterlockedDecrement64(volatile long long * const lpAddend);
__INTRIN_INLINE long long _InterlockedIncrement64(volatile long long * const lpAddend);
#endif
__INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
{
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
@ -287,7 +334,33 @@ __INTRIN_INLINE long long _InterlockedIncrement64(volatile long long * const lpA
}
#endif
#else
#else /* (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 */
__INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand);
__INTRIN_INLINE short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand);
__INTRIN_INLINE long _InterlockedCompareExchange(volatile long * const Destination, const long Exchange, const long Comperand);
__INTRIN_INLINE void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand);
__INTRIN_INLINE long _InterlockedExchange(volatile long * const Target, const long Value);
__INTRIN_INLINE void * _InterlockedExchangePointer(void * volatile * const Target, void * const Value);
__INTRIN_INLINE long _InterlockedExchangeAdd16(volatile short * const Addend, const short Value);
__INTRIN_INLINE long _InterlockedExchangeAdd(volatile long * const Addend, const long Value);
__INTRIN_INLINE char _InterlockedAnd8(volatile char * const value, const char mask);
__INTRIN_INLINE short _InterlockedAnd16(volatile short * const value, const short mask);
__INTRIN_INLINE long _InterlockedAnd(volatile long * const value, const long mask);
__INTRIN_INLINE char _InterlockedOr8(volatile char * const value, const char mask);
__INTRIN_INLINE short _InterlockedOr16(volatile short * const value, const short mask);
__INTRIN_INLINE long _InterlockedOr(volatile long * const value, const long mask);
__INTRIN_INLINE char _InterlockedXor8(volatile char * const value, const char mask);
__INTRIN_INLINE short _InterlockedXor16(volatile short * const value, const short mask);
__INTRIN_INLINE long _InterlockedXor(volatile long * const value, const long mask);
__INTRIN_INLINE long _InterlockedDecrement(volatile long * const lpAddend);
__INTRIN_INLINE long _InterlockedIncrement(volatile long * const lpAddend);
__INTRIN_INLINE short _InterlockedDecrement16(volatile short * const lpAddend);
__INTRIN_INLINE short _InterlockedIncrement16(volatile short * const lpAddend);
#if defined(_M_AMD64)
__INTRIN_INLINE long long _InterlockedDecrement64(volatile long long * const lpAddend);
__INTRIN_INLINE long long _InterlockedIncrement64(volatile long long * const lpAddend);
#endif
__INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
{
@ -530,10 +603,11 @@ __INTRIN_INLINE long long _InterlockedIncrement64(volatile long long * const lpA
}
#endif
#endif
#endif /* (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 */
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 && defined(__x86_64__)
__INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand);
__INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand)
{
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
@ -541,6 +615,7 @@ __INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * con
#else
__INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand);
__INTRIN_INLINE long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand)
{
long long retval = Comperand;
@ -609,6 +684,19 @@ __INTRIN_INLINE unsigned char _interlockedbittestandset64(volatile long long * a
#endif
/*** String operations ***/
__INTRIN_INLINE void __stosb(unsigned char * Dest, const unsigned char Data, size_t Count);
__INTRIN_INLINE void __stosw(unsigned short * Dest, const unsigned short Data, size_t Count);
__INTRIN_INLINE void __stosd(unsigned long * Dest, const unsigned long Data, size_t Count);
__INTRIN_INLINE void __movsb(unsigned char * Destination, const unsigned char * Source, size_t Count);
__INTRIN_INLINE void __movsw(unsigned short * Destination, const unsigned short * Source, size_t Count);
__INTRIN_INLINE void __movsd(unsigned long * Destination, const unsigned long * Source, size_t Count);
#ifdef _M_AMD64
__INTRIN_INLINE void __stosq(unsigned __int64 * Dest, const unsigned __int64 Data, size_t Count);
__INTRIN_INLINE void __movsq(unsigned long * Destination, const unsigned long * Source, size_t Count);
#endif
/* NOTE: we don't set a memory clobber in the __stosX functions because Visual C++ doesn't */
__INTRIN_INLINE void __stosb(unsigned char * Dest, const unsigned char Data, size_t Count)
{
@ -695,8 +783,26 @@ __INTRIN_INLINE void __movsq(unsigned long * Destination, const unsigned long *
#endif
#if defined(_M_AMD64)
/*** GS segment addressing ***/
__INTRIN_INLINE void __writegsbyte(const unsigned long Offset, const unsigned char Data);
__INTRIN_INLINE void __writegsword(const unsigned long Offset, const unsigned short Data);
__INTRIN_INLINE void __writegsdword(const unsigned long Offset, const unsigned long Data);
__INTRIN_INLINE void __writegsqword(const unsigned long Offset, const unsigned __int64 Data);
__INTRIN_INLINE unsigned char __readgsbyte(const unsigned long Offset);
__INTRIN_INLINE unsigned short __readgsword(const unsigned long Offset);
__INTRIN_INLINE unsigned long __readgsdword(const unsigned long Offset);
__INTRIN_INLINE unsigned __int64 __readgsqword(const unsigned long Offset);
__INTRIN_INLINE void __incgsbyte(const unsigned long Offset);
__INTRIN_INLINE void __incgsword(const unsigned long Offset);
__INTRIN_INLINE void __incgsdword(const unsigned long Offset);
__INTRIN_INLINE void __addgsbyte(const unsigned long Offset, const unsigned char Data);
__INTRIN_INLINE void __addgsword(const unsigned long Offset, const unsigned short Data);
__INTRIN_INLINE void __addgsdword(const unsigned long Offset, const unsigned int Data);
__INTRIN_INLINE void __addgsqword(const unsigned long Offset, const unsigned __int64 Data);
__INTRIN_INLINE void __writegsbyte(const unsigned long Offset, const unsigned char Data)
{
__asm__ __volatile__("movb %b[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "ir" (Data) : "memory");
@ -780,8 +886,24 @@ __INTRIN_INLINE void __addgsqword(const unsigned long Offset, const unsigned __i
__asm__ __volatile__("addq %k[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "ir" (Data) : "memory");
}
#else
#else /* defined(_M_AMD64) */
/*** FS segment addressing ***/
__INTRIN_INLINE void __writefsbyte(const unsigned long Offset, const unsigned char Data);
__INTRIN_INLINE void __writefsword(const unsigned long Offset, const unsigned short Data);
__INTRIN_INLINE void __writefsdword(const unsigned long Offset, const unsigned long Data);
__INTRIN_INLINE unsigned char __readfsbyte(const unsigned long Offset);
__INTRIN_INLINE unsigned short __readfsword(const unsigned long Offset);
__INTRIN_INLINE unsigned long __readfsdword(const unsigned long Offset);
__INTRIN_INLINE void __incfsbyte(const unsigned long Offset);
__INTRIN_INLINE void __incfsword(const unsigned long Offset);
__INTRIN_INLINE void __incfsdword(const unsigned long Offset);
__INTRIN_INLINE void __addfsbyte(const unsigned long Offset, const unsigned char Data);
__INTRIN_INLINE void __addfsword(const unsigned long Offset, const unsigned short Data);
__INTRIN_INLINE void __addfsdword(const unsigned long Offset, const unsigned int Data);
__INTRIN_INLINE void __writefsbyte(const unsigned long Offset, const unsigned char Data)
{
__asm__ __volatile__("movb %b[Data], %%fs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory");
@ -857,10 +979,39 @@ __INTRIN_INLINE void __addfsdword(const unsigned long Offset, const unsigned int
else
__asm__ __volatile__("addl %k[Data], %%fs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory");
}
#endif
#endif /* defined(_M_AMD64) */
/*** Bit manipulation ***/
__INTRIN_INLINE unsigned char _BitScanForward(unsigned long * const Index, const unsigned long Mask);
__INTRIN_INLINE unsigned char _BitScanReverse(unsigned long * const Index, const unsigned long Mask);
__INTRIN_INLINE unsigned char _bittest(const long * const a, const long b);
#ifdef _M_AMD64
__INTRIN_INLINE unsigned char _bittest64(const __int64 * const a, const __int64 b);
#endif
__INTRIN_INLINE unsigned char _bittestandcomplement(long * const a, const long b);
__INTRIN_INLINE unsigned char _bittestandreset(long * const a, const long b);
__INTRIN_INLINE unsigned char _bittestandset(long * const a, const long b);
__INTRIN_INLINE unsigned char _rotl8(unsigned char value, unsigned char shift);
__INTRIN_INLINE unsigned short _rotl16(unsigned short value, unsigned char shift);
__INTRIN_INLINE unsigned int _rotl(unsigned int value, int shift);
__INTRIN_INLINE unsigned int _rotr(unsigned int value, int shift);
__INTRIN_INLINE unsigned char _rotr8(unsigned char value, unsigned char shift);
__INTRIN_INLINE unsigned short _rotr16(unsigned short value, unsigned char shift);
__INTRIN_INLINE unsigned long long __ll_lshift(const unsigned long long Mask, const int Bit);
__INTRIN_INLINE long long __ll_rshift(const long long Mask, const int Bit);
__INTRIN_INLINE unsigned long long __ull_rshift(const unsigned long long Mask, int Bit);
__INTRIN_INLINE unsigned short _byteswap_ushort(unsigned short value);
__INTRIN_INLINE unsigned long _byteswap_ulong(unsigned long value);
#ifdef _M_AMD64
__INTRIN_INLINE unsigned __int64 _byteswap_uint64(unsigned __int64 value);
#else
__INTRIN_INLINE unsigned __int64 _byteswap_uint64(unsigned __int64 value);
#endif
__INTRIN_INLINE unsigned char _BitScanForward(unsigned long * const Index, const unsigned long Mask)
{
__asm__("bsfl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask));
@ -1001,11 +1152,11 @@ __INTRIN_INLINE unsigned long long __ll_lshift(const unsigned long long Mask, co
__INTRIN_INLINE long long __ll_rshift(const long long Mask, const int Bit)
{
unsigned long long retval = Mask;
long long retval = Mask;
__asm__
(
"shldl %b[Bit], %%eax, %%edx; sarl %b[Bit], %%eax" :
"shrdl %b[Bit], %%edx, %%eax; sarl %b[Bit], %%edx" :
"+A" (retval) :
[Bit] "Nc" ((unsigned char)((unsigned long)Bit) & 0xFF)
);
@ -1019,7 +1170,7 @@ __INTRIN_INLINE unsigned long long __ull_rshift(const unsigned long long Mask, i
__asm__
(
"shrdl %b[Bit], %%eax, %%edx; shrl %b[Bit], %%eax" :
"shrdl %b[Bit], %%edx, %%eax; shrl %b[Bit], %%edx" :
"+A" (retval) :
[Bit] "Nc" ((unsigned char)((unsigned long)Bit) & 0xFF)
);
@ -1052,7 +1203,7 @@ __INTRIN_INLINE unsigned __int64 _byteswap_uint64(unsigned __int64 value)
__INTRIN_INLINE unsigned __int64 _byteswap_uint64(unsigned __int64 value)
{
union {
__int64 int64part;
unsigned __int64 int64part;
struct {
unsigned long lowpart;
unsigned long hipart;
@ -1067,6 +1218,15 @@ __INTRIN_INLINE unsigned __int64 _byteswap_uint64(unsigned __int64 value)
#endif
/*** 64-bit math ***/
__INTRIN_INLINE long long __emul(const int a, const int b);
__INTRIN_INLINE unsigned long long __emulu(const unsigned int a, const unsigned int b);
#ifdef _M_AMD64
__INTRIN_INLINE __int64 __mulh(__int64 a, __int64 b);
__INTRIN_INLINE unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b);
#endif
__INTRIN_INLINE long long __emul(const int a, const int b)
{
long long retval;
@ -1100,6 +1260,27 @@ __INTRIN_INLINE unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b)
#endif
/*** Port I/O ***/
__INTRIN_INLINE unsigned char __inbyte(const unsigned short Port);
__INTRIN_INLINE unsigned short __inword(const unsigned short Port);
__INTRIN_INLINE unsigned long __indword(const unsigned short Port);
__INTRIN_INLINE void __inbytestring(unsigned short Port, unsigned char * Buffer, unsigned long Count);
__INTRIN_INLINE void __inwordstring(unsigned short Port, unsigned short * Buffer, unsigned long Count);
__INTRIN_INLINE void __indwordstring(unsigned short Port, unsigned long * Buffer, unsigned long Count);
__INTRIN_INLINE void __outbyte(unsigned short const Port, const unsigned char Data);
__INTRIN_INLINE void __outword(unsigned short const Port, const unsigned short Data);
__INTRIN_INLINE void __outdword(unsigned short const Port, const unsigned long Data);
__INTRIN_INLINE void __outbytestring(unsigned short const Port, const unsigned char * const Buffer, const unsigned long Count);
__INTRIN_INLINE void __outwordstring(unsigned short const Port, const unsigned short * const Buffer, const unsigned long Count);
__INTRIN_INLINE void __outdwordstring(unsigned short const Port, const unsigned long * const Buffer, const unsigned long Count);
__INTRIN_INLINE int _inp(unsigned short Port);
__INTRIN_INLINE unsigned short _inpw(unsigned short Port);
__INTRIN_INLINE unsigned long _inpd(unsigned short Port);
__INTRIN_INLINE int _outp(unsigned short Port, int databyte);
__INTRIN_INLINE unsigned short _outpw(unsigned short Port, unsigned short dataword);
__INTRIN_INLINE unsigned long _outpd(unsigned short Port, unsigned long dataword);
__INTRIN_INLINE unsigned char __inbyte(const unsigned short Port)
{
unsigned char byte;
@ -1201,7 +1382,7 @@ __INTRIN_INLINE unsigned long _inpd(unsigned short Port)
__INTRIN_INLINE int _outp(unsigned short Port, int databyte)
{
__outbyte(Port, databyte);
__outbyte(Port, (unsigned char)databyte);
return databyte;
}
@ -1219,6 +1400,13 @@ __INTRIN_INLINE unsigned long _outpd(unsigned short Port, unsigned long dataword
/*** System information ***/
__INTRIN_INLINE void __cpuid(int CPUInfo [], const int InfoType);
__INTRIN_INLINE unsigned long long __rdtsc(void);
__INTRIN_INLINE void __writeeflags(uintptr_t Value);
__INTRIN_INLINE uintptr_t __readeflags(void);
__INTRIN_INLINE void __cpuid(int CPUInfo[], const int InfoType)
{
__asm__ __volatile__("cpuid" : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : "a" (InfoType));
@ -1250,9 +1438,16 @@ __INTRIN_INLINE uintptr_t __readeflags(void)
}
/*** Interrupts ***/
__INTRIN_INLINE void __int2c(void);
__INTRIN_INLINE void _disable(void);
__INTRIN_INLINE void _enable(void);
__INTRIN_INLINE void __halt(void);
#ifdef __clang__
#define __debugbreak() __asm__("int $3")
#else
__INTRIN_INLINE void __debugbreak(void);
__INTRIN_INLINE void __debugbreak(void)
{
__asm__("int $3");
@ -1281,7 +1476,34 @@ __INTRIN_INLINE void __halt(void)
/*** Protected memory management ***/
__INTRIN_INLINE void __invlpg(void * const Address);
#ifdef _M_AMD64
__INTRIN_INLINE void __writecr0(const unsigned __int64 Data);
__INTRIN_INLINE void __writecr3(const unsigned __int64 Data);
__INTRIN_INLINE void __writecr4(const unsigned __int64 Data);
__INTRIN_INLINE void __writecr8(const unsigned __int64 Data);
__INTRIN_INLINE unsigned __int64 __readcr0(void);
__INTRIN_INLINE unsigned __int64 __readcr2(void);
__INTRIN_INLINE unsigned __int64 __readcr3(void);
__INTRIN_INLINE unsigned __int64 __readcr4(void);
__INTRIN_INLINE unsigned __int64 __readcr8(void);
__INTRIN_INLINE unsigned __int64 __readdr(unsigned int reg);
__INTRIN_INLINE void __writedr(unsigned reg, unsigned __int64 value);
#else /* _M_AMD64 */
__INTRIN_INLINE void __writecr0(const unsigned int Data);
__INTRIN_INLINE void __writecr3(const unsigned int Data);
__INTRIN_INLINE void __writecr4(const unsigned int Data);
__INTRIN_INLINE unsigned long __readcr0(void);
__INTRIN_INLINE unsigned long __readcr2(void);
__INTRIN_INLINE unsigned long __readcr3(void);
__INTRIN_INLINE unsigned long __readcr4(void);
__INTRIN_INLINE unsigned int __readdr(unsigned int reg);
__INTRIN_INLINE void __writedr(unsigned reg, unsigned int value);
#endif /* _M_AMD64 */
#ifdef _M_AMD64
__INTRIN_INLINE void __writecr0(const unsigned __int64 Data)
{
__asm__("mov %[Data], %%cr0" : : [Data] "r" (Data) : "memory");
@ -1336,7 +1558,9 @@ __INTRIN_INLINE unsigned __int64 __readcr8(void)
__asm__ __volatile__("movq %%cr8, %q[value]" : [value] "=r" (value));
return value;
}
#else
#else /* _M_AMD64 */
__INTRIN_INLINE void __writecr0(const unsigned int Data)
{
__asm__("mov %[Data], %%cr0" : : [Data] "r" (Data) : "memory");
@ -1379,9 +1603,11 @@ __INTRIN_INLINE unsigned long __readcr4(void)
__asm__ __volatile__("mov %%cr4, %[value]" : [value] "=r" (value));
return value;
}
#endif
#endif /* _M_AMD64 */
#ifdef _M_AMD64
__INTRIN_INLINE unsigned __int64 __readdr(unsigned int reg)
{
unsigned __int64 value;
@ -1445,7 +1671,9 @@ __INTRIN_INLINE void __writedr(unsigned reg, unsigned __int64 value)
break;
}
}
#else
#else /* _M_AMD64 */
__INTRIN_INLINE unsigned int __readdr(unsigned int reg)
{
unsigned int value;
@ -1509,7 +1737,8 @@ __INTRIN_INLINE void __writedr(unsigned reg, unsigned int value)
break;
}
}
#endif
#endif /* _M_AMD64 */
__INTRIN_INLINE void __invlpg(void * const Address)
{
@ -1518,6 +1747,16 @@ __INTRIN_INLINE void __invlpg(void * const Address)
/*** System operations ***/
__INTRIN_INLINE unsigned long long __readmsr(const int reg);
__INTRIN_INLINE void __writemsr(const unsigned long Register, const unsigned long long Value);
__INTRIN_INLINE unsigned long long __readpmc(const int counter);
__INTRIN_INLINE unsigned long __segmentlimit(const unsigned long a);
__INTRIN_INLINE void __wbinvd(void);
__INTRIN_INLINE void __lidt(void *Source);
__INTRIN_INLINE void __sidt(void *Destination);
__INTRIN_INLINE unsigned long long __readmsr(const int reg)
{
#ifdef _M_AMD64
@ -1572,6 +1811,9 @@ __INTRIN_INLINE void __sidt(void *Destination)
/*** Misc operations ***/
__INTRIN_INLINE void _mm_pause(void);
__INTRIN_INLINE void __nop(void);
__INTRIN_INLINE void _mm_pause(void)
{
__asm__ __volatile__("pause" : : : "memory");

View file

@ -3,6 +3,7 @@
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#ifndef _INC_TCHAR_S
#define _INC_TCHAR_S
@ -107,7 +108,7 @@ extern "C" {
#define _wcsnset_s_l(_Destination,_Destination_size_chars,_Value,_Count,_Locale) (_wcsnset_s(_Destination,_Destination_size_chars,_Value,_Count))
#define _wcsset_s_l(_Destination,_Destination_size_chars,_Value,_Locale) (_wcsset_s(_Destination,_Destination_size_chars,_Value))
#else
#else /* _UNICODE */
#define _tprintf_s printf_s
#define _tprintf_s_l _printf_s_l
@ -208,28 +209,156 @@ extern "C" {
#define _tccpy_s _mbccpy_s
#define _tccpy_s_l _mbccpy_s_l
#else
_CRTIMP char *__cdecl _tcsncat_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
_CRTIMP char *__cdecl _tcsncat_s_l(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP char *__cdecl _tcsncpy_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
_CRTIMP char *__cdecl _tcsncpy_s_l(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP char *__cdecl _tcstok_s(char *_Str,const char *_Delim,char **_Context);
_CRTIMP char *__cdecl _tcstok_s_l(char *_Str,const char *_Delim,char **_Context,_locale_t _Locale);
_CRTIMP errno_t __cdecl _tcsset_s(char *_Str,size_t _SizeInChars,unsigned int _Val);
_CRTIMP errno_t __cdecl _tcsset_s_l(char *_Str,size_t _SizeInChars,unsigned int,_locale_t _Locale);
_CRTIMP char *__cdecl _tcsnccat_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
_CRTIMP char *__cdecl _tcsnccat_s_l(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP char *__cdecl _tcsnccpy_s(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount);
_CRTIMP char *__cdecl _tcsnccpy_s_l(char *_Dst,size_t _DstSizeInChars,const char *_Src,size_t _MaxCount,_locale_t _Locale);
_CRTIMP char *__cdecl _tcslwr_s(char *_Str,size_t _SizeInChars);
_CRTIMP char *__cdecl _tcslwr_s_l(char *_Str,size_t _SizeInChars,_locale_t _Locale);
_CRTIMP char *__cdecl _tcsupr_s(char *_Str,size_t _SizeInChars);
_CRTIMP char *__cdecl _tcsupr_s_l(char *_Str,size_t _SizeInChars,_locale_t _Locale);
#else /* _MB_MAP_DIRECT */
#endif
_CRTIMP
char *
__cdecl
_tcsncat_s(
_Inout_updates_z_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount);
#else
_CRTIMP
char *
__cdecl
_tcsncat_s_l(
_Inout_updates_z_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount,
_In_opt_ _locale_t _Locale);
_CRTIMP
char *
__cdecl
_tcsncpy_s(
_Out_writes_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount);
_CRTIMP
char *
__cdecl
_tcsncpy_s_l(
_Out_writes_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount,
_In_opt_ _locale_t _Locale);
_Check_return_
_CRTIMP
char *
__cdecl
_tcstok_s(
_Inout_opt_ char *_Str,
_In_z_ const char *_Delim,
_Inout_ _Deref_prepost_opt_z_ char **_Context);
_Check_return_
_CRTIMP
char *
__cdecl
_tcstok_s_l(
_Inout_opt_ char *_Str,
_In_z_ const char *_Delim,
_Inout_ _Deref_prepost_opt_z_ char **_Context,
_In_opt_ _locale_t _Locale);
_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_tcsset_s(
_Inout_updates_z_(_SizeInChars) char *_Str,
_In_ size_t _SizeInChars,
_In_ unsigned int _Val);
_Check_return_wat_
_CRTIMP
errno_t
__cdecl
_tcsset_s_l(
_Inout_updates_z_(_SizeInChars) char *_Str,
_In_ size_t _SizeInChars,
_In_ unsigned int,
_In_opt_ _locale_t _Locale);
_CRTIMP
char *
__cdecl
_tcsnccat_s(
_Inout_updates_z_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount);
_CRTIMP
char *
__cdecl
_tcsnccat_s_l(
_Inout_updates_z_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount,
_In_opt_ _locale_t _Locale);
_CRTIMP
char *
__cdecl
_tcsnccpy_s(
_Out_writes_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount);
_CRTIMP
char *
__cdecl
_tcsnccpy_s_l(
_Out_writes_(_DstSizeInChars) char *_Dst,
_In_ size_t _DstSizeInChars,
_In_z_ const char *_Src,
_In_ size_t _MaxCount,
_In_opt_ _locale_t _Locale);
_CRTIMP
char *
__cdecl
_tcslwr_s(
_Inout_updates_z_(_SizeInChars) char *_Str,
_In_ size_t _SizeInChars);
_CRTIMP
char *
__cdecl
_tcslwr_s_l(
_Inout_updates_z_(_SizeInChars) char *_Str,
_In_ size_t _SizeInChars,
_In_opt_ _locale_t _Locale);
_CRTIMP
char *
__cdecl
_tcsupr_s(
_Inout_updates_z_(_SizeInChars) char *_Str,
_In_ size_t _SizeInChars);
_CRTIMP
char *
__cdecl
_tcsupr_s_l(
_Inout_updates_z_(_SizeInChars) char *_Str,
_In_ size_t _SizeInChars,
_In_opt_ _locale_t _Locale);
#endif /* _MB_MAP_DIRECT */
#else /* _MBCS */
#define _tcsncat_s strncat_s
#define _tcsncat_s_l _strncat_s_l
@ -256,11 +385,15 @@ extern "C" {
#define _strnset_s_l(_Destination,_Destination_size_chars,_Value,_Count,_Locale) (_strnset_s(_Destination,_Destination_size_chars,_Value,_Count))
#define _strset_s_l(_Destination,_Destination_size_chars,_Value,_Locale) (_strset_s(_Destination,_Destination_size_chars,_Value))
#endif
#endif
#endif /* _MBCS */
#endif /* _UNICODE */
#ifdef __cplusplus
}
#endif
#endif
#endif
#endif /* MINGW_HAS_SECURE_API */
#endif /* _INC_TCHAR_S */

View file

@ -1702,194 +1702,711 @@ typedef struct tagMCI_WAVE_SET_PARMS {
WORD wReserved5;
} MCI_WAVE_SET_PARMS,*PMCI_WAVE_SET_PARMS,*LPMCI_WAVE_SET_PARMS;
LRESULT WINAPI CloseDriver(HDRVR,LPARAM,LPARAM);
HDRVR WINAPI OpenDriver(LPCWSTR,LPCWSTR,LPARAM);
LRESULT WINAPI SendDriverMessage(HDRVR,UINT,LPARAM,LPARAM);
HMODULE WINAPI DrvGetModuleHandle(HDRVR);
HMODULE WINAPI GetDriverModuleHandle(HDRVR);
LRESULT WINAPI DefDriverProc(DWORD_PTR,HDRVR,UINT,LPARAM,LPARAM);
LRESULT WINAPI CloseDriver(_In_ HDRVR, _In_ LPARAM, _In_ LPARAM);
HDRVR WINAPI OpenDriver(_In_ LPCWSTR, _In_ LPCWSTR, _In_ LPARAM);
LRESULT WINAPI SendDriverMessage(_In_ HDRVR, _In_ UINT, _In_ LPARAM, _In_ LPARAM);
HMODULE WINAPI DrvGetModuleHandle(_In_ HDRVR);
HMODULE WINAPI GetDriverModuleHandle(_In_ HDRVR);
LRESULT
WINAPI
DefDriverProc(
_In_ DWORD_PTR,
_In_ HDRVR,
_In_ UINT,
_In_ LPARAM,
_In_ LPARAM);
UINT WINAPI mmsystemGetVersion(void);
#define OutputDebugStr OutputDebugString
BOOL WINAPI sndPlaySoundA(LPCSTR,UINT);
BOOL WINAPI sndPlaySoundW(LPCWSTR,UINT);
BOOL WINAPI PlaySoundA(LPCSTR,HMODULE,DWORD);
BOOL WINAPI PlaySoundW(LPCWSTR,HMODULE,DWORD);
BOOL WINAPI sndPlaySoundA(_In_opt_ LPCSTR, _In_ UINT);
BOOL WINAPI sndPlaySoundW(_In_opt_ LPCWSTR, _In_ UINT);
BOOL WINAPI PlaySoundA(_In_opt_ LPCSTR, _In_opt_ HMODULE, _In_ DWORD);
BOOL WINAPI PlaySoundW(_In_opt_ LPCWSTR, _In_opt_ HMODULE, _In_ DWORD);
UINT WINAPI waveOutGetNumDevs(void);
MMRESULT WINAPI waveOutGetDevCapsA(UINT_PTR,LPWAVEOUTCAPSA,UINT);
MMRESULT WINAPI waveOutGetDevCapsW(UINT_PTR,LPWAVEOUTCAPSW,UINT);
MMRESULT WINAPI waveOutGetVolume(HWAVEOUT,PDWORD);
MMRESULT WINAPI waveOutSetVolume(HWAVEOUT,DWORD);
MMRESULT WINAPI waveOutGetErrorTextA(MMRESULT,LPSTR,UINT);
MMRESULT WINAPI waveOutGetErrorTextW(MMRESULT,LPWSTR,UINT);
MMRESULT WINAPI waveOutOpen(LPHWAVEOUT,UINT,LPCWAVEFORMATEX,DWORD_PTR,DWORD_PTR,DWORD);
MMRESULT WINAPI waveOutClose(HWAVEOUT);
MMRESULT WINAPI waveOutPrepareHeader(HWAVEOUT,LPWAVEHDR,UINT);
MMRESULT WINAPI waveOutUnprepareHeader(HWAVEOUT,LPWAVEHDR,UINT);
MMRESULT WINAPI waveOutWrite(HWAVEOUT,LPWAVEHDR,UINT);
MMRESULT WINAPI waveOutPause(HWAVEOUT);
MMRESULT WINAPI waveOutRestart(HWAVEOUT);
MMRESULT WINAPI waveOutReset(HWAVEOUT);
MMRESULT WINAPI waveOutBreakLoop(HWAVEOUT);
MMRESULT WINAPI waveOutGetPosition(HWAVEOUT,LPMMTIME,UINT);
MMRESULT WINAPI waveOutGetPitch(HWAVEOUT,PDWORD);
MMRESULT WINAPI waveOutSetPitch(HWAVEOUT,DWORD);
MMRESULT WINAPI waveOutGetPlaybackRate(HWAVEOUT,PDWORD);
MMRESULT WINAPI waveOutSetPlaybackRate(HWAVEOUT,DWORD);
MMRESULT WINAPI waveOutGetID(HWAVEOUT,LPUINT);
MMRESULT WINAPI waveOutGetDevCapsA(_In_ UINT_PTR, _Out_ LPWAVEOUTCAPSA, _In_ UINT);
MMRESULT WINAPI waveOutGetDevCapsW(_In_ UINT_PTR, _Out_ LPWAVEOUTCAPSW, _In_ UINT);
MMRESULT WINAPI waveOutGetVolume(_In_opt_ HWAVEOUT, _Out_ PDWORD);
MMRESULT WINAPI waveOutSetVolume(_In_opt_ HWAVEOUT, _In_ DWORD);
MMRESULT
WINAPI
waveOutGetErrorTextA(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
waveOutGetErrorTextW(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPWSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
waveOutOpen(
_Out_opt_ LPHWAVEOUT,
_In_ UINT,
_In_ LPCWAVEFORMATEX,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR,
_In_ DWORD);
MMRESULT WINAPI waveOutClose(_In_ HWAVEOUT);
MMRESULT
WINAPI
waveOutPrepareHeader(
_In_ HWAVEOUT hwo,
_Inout_updates_bytes_(cbwh) LPWAVEHDR pwh,
_In_ UINT cbwh);
MMRESULT
WINAPI
waveOutUnprepareHeader(
_In_ HWAVEOUT hwo,
_Inout_updates_bytes_(cbwh) LPWAVEHDR pwh,
_In_ UINT cbwh);
MMRESULT
WINAPI
waveOutWrite(
_In_ HWAVEOUT hwo,
_Inout_updates_bytes_(cbwh) LPWAVEHDR pwh,
_In_ UINT cbwh);
MMRESULT WINAPI waveOutPause(_In_ HWAVEOUT);
MMRESULT WINAPI waveOutRestart(_In_ HWAVEOUT);
MMRESULT WINAPI waveOutReset(_In_ HWAVEOUT);
MMRESULT WINAPI waveOutBreakLoop(_In_ HWAVEOUT);
MMRESULT
WINAPI
waveOutGetPosition(
_In_ HWAVEOUT hwo,
_Inout_updates_bytes_(cbmmt) LPMMTIME pmmt,
_In_ UINT cbmmt);
MMRESULT WINAPI waveOutGetPitch(_In_ HWAVEOUT, _Out_ PDWORD);
MMRESULT WINAPI waveOutSetPitch(_In_ HWAVEOUT, _In_ DWORD);
MMRESULT WINAPI waveOutGetPlaybackRate(_In_ HWAVEOUT, _Out_ PDWORD);
MMRESULT WINAPI waveOutSetPlaybackRate(_In_ HWAVEOUT, _In_ DWORD);
MMRESULT WINAPI waveOutGetID(_In_ HWAVEOUT, _Out_ LPUINT);
#if (WINVER >= 0x030a)
#ifdef _WIN32
MMRESULT WINAPI waveOutMessage(HWAVEOUT,UINT,DWORD_PTR,DWORD_PTR);
MMRESULT WINAPI waveOutMessage(_In_opt_ HWAVEOUT, _In_ UINT, _In_ DWORD_PTR, _In_ DWORD_PTR);
#else
DWORD WINAPI waveOutMessage(HWAVEOUT,UINT,DWORD,DWORD);
#endif
#endif
UINT WINAPI waveInGetNumDevs(void);
MMRESULT WINAPI waveInGetDevCapsA(UINT_PTR,LPWAVEINCAPSA,UINT);
MMRESULT WINAPI waveInGetDevCapsW(UINT_PTR,LPWAVEINCAPSW,UINT);
MMRESULT WINAPI waveInGetErrorTextA(MMRESULT,LPSTR,UINT);
MMRESULT WINAPI waveInGetErrorTextW(MMRESULT,LPWSTR,UINT);
MMRESULT WINAPI waveInOpen(LPHWAVEIN,UINT,LPCWAVEFORMATEX,DWORD_PTR,DWORD_PTR,DWORD);
MMRESULT WINAPI waveInClose(HWAVEIN);
MMRESULT WINAPI waveInPrepareHeader(HWAVEIN,LPWAVEHDR,UINT);
MMRESULT WINAPI waveInUnprepareHeader(HWAVEIN,LPWAVEHDR,UINT);
MMRESULT WINAPI waveInAddBuffer(HWAVEIN,LPWAVEHDR,UINT);
MMRESULT WINAPI waveInStart(HWAVEIN);
MMRESULT WINAPI waveInStop(HWAVEIN);
MMRESULT WINAPI waveInReset(HWAVEIN);
MMRESULT WINAPI waveInGetPosition(HWAVEIN,LPMMTIME,UINT);
MMRESULT WINAPI waveInGetID(HWAVEIN,LPUINT);
MMRESULT
WINAPI
waveInGetDevCapsA(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbwic) LPWAVEINCAPSA pwic,
_In_ UINT cbwic);
MMRESULT
WINAPI
waveInGetDevCapsW(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbwic) LPWAVEINCAPSW pwic,
_In_ UINT cbwic);
MMRESULT
WINAPI
waveInGetErrorTextA(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
waveInGetErrorTextW(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPWSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
waveInOpen(
_Out_opt_ LPHWAVEIN,
_In_ UINT,
_In_ LPCWAVEFORMATEX,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR,
_In_ DWORD);
MMRESULT WINAPI waveInClose(_In_ HWAVEIN);
MMRESULT
WINAPI
waveInPrepareHeader(
_In_ HWAVEIN hwi,
_Inout_updates_bytes_(cbwh) LPWAVEHDR pwh,
_In_ UINT cbwh);
MMRESULT
WINAPI
waveInUnprepareHeader(
_In_ HWAVEIN hwi,
_Inout_updates_bytes_(cbwh) LPWAVEHDR pwh,
_In_ UINT cbwh);
MMRESULT
WINAPI
waveInAddBuffer(
_In_ HWAVEIN hwi,
_Inout_updates_bytes_(cbwh) LPWAVEHDR pwh,
_In_ UINT cbwh);
MMRESULT WINAPI waveInStart(_In_ HWAVEIN);
MMRESULT WINAPI waveInStop(_In_ HWAVEIN);
MMRESULT WINAPI waveInReset(_In_ HWAVEIN);
MMRESULT
WINAPI
waveInGetPosition(
_In_ HWAVEIN hwi,
_Inout_updates_bytes_(cbmmt) LPMMTIME pmmt,
_In_ UINT cbmmt);
MMRESULT WINAPI waveInGetID(_In_ HWAVEIN, _In_ LPUINT);
#if (WINVER >= 0x030a)
#ifdef _WIN32
MMRESULT WINAPI waveInMessage(HWAVEIN,UINT,DWORD_PTR,DWORD_PTR);
MMRESULT WINAPI waveInMessage(_In_opt_ HWAVEIN, _In_ UINT, _In_opt_ DWORD_PTR, _In_opt_ DWORD_PTR);
#else
DWORD WINAPI waveInMessage(HWAVEIN,UINT,DWORD,DWORD);
#endif
#endif
UINT WINAPI midiOutGetNumDevs(void);
MMRESULT WINAPI midiStreamOpen(LPHMIDISTRM,LPUINT,DWORD,DWORD_PTR,DWORD_PTR,DWORD);
MMRESULT WINAPI midiStreamClose(HMIDISTRM);
MMRESULT WINAPI midiStreamProperty(HMIDISTRM,LPBYTE,DWORD);
MMRESULT WINAPI midiStreamPosition(HMIDISTRM,LPMMTIME,UINT);
MMRESULT WINAPI midiStreamOut(HMIDISTRM,LPMIDIHDR,UINT);
MMRESULT WINAPI midiStreamPause(HMIDISTRM);
MMRESULT WINAPI midiStreamRestart(HMIDISTRM);
MMRESULT WINAPI midiStreamStop(HMIDISTRM);
MMRESULT WINAPI midiConnect(HMIDI,HMIDIOUT,PVOID);
MMRESULT WINAPI midiDisconnect(HMIDI,HMIDIOUT,PVOID);
MMRESULT WINAPI midiOutGetDevCapsA(UINT_PTR,LPMIDIOUTCAPSA,UINT);
MMRESULT WINAPI midiOutGetDevCapsW(UINT_PTR,LPMIDIOUTCAPSW,UINT);
MMRESULT WINAPI midiOutGetVolume(HMIDIOUT,PDWORD);
MMRESULT WINAPI midiOutSetVolume(HMIDIOUT,DWORD);
MMRESULT WINAPI midiOutGetErrorTextA(MMRESULT,LPSTR,UINT);
MMRESULT WINAPI midiOutGetErrorTextW(MMRESULT,LPWSTR,UINT);
MMRESULT WINAPI midiOutOpen(LPHMIDIOUT,UINT,DWORD_PTR,DWORD_PTR,DWORD);
MMRESULT WINAPI midiOutClose(HMIDIOUT);
MMRESULT WINAPI midiOutPrepareHeader(HMIDIOUT,LPMIDIHDR,UINT);
MMRESULT WINAPI midiOutUnprepareHeader(HMIDIOUT,LPMIDIHDR,UINT);
MMRESULT WINAPI midiOutShortMsg(HMIDIOUT,DWORD);
MMRESULT WINAPI midiOutLongMsg(HMIDIOUT,LPMIDIHDR,UINT);
MMRESULT WINAPI midiOutReset(HMIDIOUT);
MMRESULT WINAPI midiOutCachePatches(HMIDIOUT,UINT,LPWORD,UINT);
MMRESULT WINAPI midiOutCacheDrumPatches(HMIDIOUT,UINT,LPWORD,UINT);
MMRESULT WINAPI midiOutGetID(HMIDIOUT,LPUINT);
MMRESULT
WINAPI
midiStreamOpen(
_Out_ LPHMIDISTRM phms,
_Inout_updates_(cMidi) LPUINT puDeviceID,
_In_ DWORD cMidi,
_In_opt_ DWORD_PTR dwCallback,
_In_opt_ DWORD_PTR dwInstance,
_In_ DWORD fdwOpen);
MMRESULT WINAPI midiStreamClose(_In_ HMIDISTRM);
MMRESULT
WINAPI
midiStreamProperty(
_In_ HMIDISTRM hms,
_Inout_updates_bytes_(sizeof(DWORD) + sizeof(DWORD)) LPBYTE lppropdata,
_In_ DWORD dwProperty);
MMRESULT
WINAPI
midiStreamPosition(
_In_ HMIDISTRM hms,
_Out_writes_bytes_(cbmmt) LPMMTIME lpmmt,
_In_ UINT cbmmt);
MMRESULT
WINAPI
midiStreamOut(
_In_ HMIDISTRM hms,
_Out_writes_bytes_(cbmh) LPMIDIHDR pmh,
_In_ UINT cbmh);
MMRESULT WINAPI midiStreamPause(_In_ HMIDISTRM);
MMRESULT WINAPI midiStreamRestart(_In_ HMIDISTRM);
MMRESULT WINAPI midiStreamStop(_In_ HMIDISTRM);
MMRESULT WINAPI midiConnect(_In_ HMIDI, _In_ HMIDIOUT, _In_opt_ PVOID);
MMRESULT WINAPI midiDisconnect(_In_ HMIDI, _In_ HMIDIOUT, _In_opt_ PVOID);
MMRESULT
WINAPI
midiOutGetDevCapsA(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbmoc) LPMIDIOUTCAPSA pmoc,
_In_ UINT cbmoc);
MMRESULT
WINAPI
midiOutGetDevCapsW(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbmoc) LPMIDIOUTCAPSW pmoc,
_In_ UINT cbmoc);
MMRESULT WINAPI midiOutGetVolume(_In_opt_ HMIDIOUT, _Out_ PDWORD);
MMRESULT WINAPI midiOutSetVolume(_In_opt_ HMIDIOUT, _In_ DWORD);
MMRESULT
WINAPI
midiOutGetErrorTextA(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
midiOutGetErrorTextW(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPWSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
midiOutOpen(
_Out_ LPHMIDIOUT,
_In_ UINT,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR,
_In_ DWORD);
MMRESULT WINAPI midiOutClose(_In_ HMIDIOUT);
MMRESULT
WINAPI
midiOutPrepareHeader(
_In_ HMIDIOUT hmo,
_Inout_updates_bytes_(cbmh) LPMIDIHDR pmh,
_In_ UINT cbmh);
MMRESULT
WINAPI
midiOutUnprepareHeader(
_In_ HMIDIOUT hmo,
_Inout_updates_bytes_(cbmh) LPMIDIHDR pmh,
_In_ UINT cbmh);
MMRESULT WINAPI midiOutShortMsg(_In_ HMIDIOUT, _In_ DWORD);
MMRESULT
WINAPI
midiOutLongMsg(
_In_ HMIDIOUT hmo,
_In_reads_bytes_(cbmh) LPMIDIHDR pmh,
_In_ UINT cbmh);
MMRESULT WINAPI midiOutReset(_In_ HMIDIOUT);
MMRESULT
WINAPI
midiOutCachePatches(
_In_ HMIDIOUT hmo,
_In_ UINT uBank,
_In_reads_(MIDIPATCHSIZE) LPWORD pwpa,
_In_ UINT fuCache);
MMRESULT
WINAPI
midiOutCacheDrumPatches(
_In_ HMIDIOUT hmo,
_In_ UINT uPatch,
_In_reads_(MIDIPATCHSIZE) LPWORD pwkya,
_In_ UINT fuCache);
MMRESULT WINAPI midiOutGetID(_In_ HMIDIOUT, _Out_ LPUINT);
#if (WINVER >= 0x030a)
#ifdef _WIN32
MMRESULT WINAPI midiOutMessage(HMIDIOUT,UINT,DWORD_PTR,DWORD_PTR);
MMRESULT WINAPI midiOutMessage(_In_opt_ HMIDIOUT, _In_ UINT, _In_opt_ DWORD_PTR, _In_opt_ DWORD_PTR);
#else
DWORD WINAPI midiOutMessage(HMIDIOUT,UINT,DWORD,DWORD);
#endif
#endif
UINT WINAPI midiInGetNumDevs(void);
MMRESULT WINAPI midiInGetDevCapsA(UINT_PTR,LPMIDIINCAPSA,UINT);
MMRESULT WINAPI midiInGetDevCapsW(UINT_PTR,LPMIDIINCAPSW,UINT);
MMRESULT WINAPI midiInGetErrorTextA(MMRESULT,LPSTR,UINT);
MMRESULT WINAPI midiInGetErrorTextW(MMRESULT,LPWSTR,UINT);
MMRESULT WINAPI midiInOpen(LPHMIDIIN,UINT,DWORD_PTR,DWORD_PTR,DWORD);
MMRESULT WINAPI midiInClose(HMIDIIN);
MMRESULT WINAPI midiInPrepareHeader(HMIDIIN,LPMIDIHDR,UINT);
MMRESULT WINAPI midiInUnprepareHeader(HMIDIIN,LPMIDIHDR,UINT);
MMRESULT WINAPI midiInAddBuffer(HMIDIIN,LPMIDIHDR,UINT);
MMRESULT WINAPI midiInStart(HMIDIIN);
MMRESULT WINAPI midiInStop(HMIDIIN);
MMRESULT WINAPI midiInReset(HMIDIIN);
MMRESULT WINAPI midiInGetID(HMIDIIN,LPUINT);
MMRESULT
WINAPI
midiInGetDevCapsA(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbmic) LPMIDIINCAPSA pmic,
_In_ UINT cbmic);
MMRESULT
WINAPI
midiInGetDevCapsW(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbmic) LPMIDIINCAPSW pmic,
_In_ UINT cbmic);
MMRESULT
WINAPI
midiInGetErrorTextA(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
midiInGetErrorTextW(
_In_ MMRESULT mmrError,
_Out_writes_(cchText) LPWSTR pszText,
_In_ UINT cchText);
MMRESULT
WINAPI
midiInOpen(
_Out_ LPHMIDIIN,
_In_ UINT,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR,
_In_ DWORD);
MMRESULT WINAPI midiInClose(_In_ HMIDIIN);
MMRESULT
WINAPI
midiInPrepareHeader(
_In_ HMIDIIN hmi,
_Inout_updates_bytes_(cbmh) LPMIDIHDR pmh,
_In_ UINT cbmh);
MMRESULT
WINAPI
midiInUnprepareHeader(
_In_ HMIDIIN hmi,
_Inout_updates_bytes_(cbmh) LPMIDIHDR pmh,
_In_ UINT cbmh);
MMRESULT
WINAPI
midiInAddBuffer(
_In_ HMIDIIN hmi,
_Out_writes_bytes_(cbmh) LPMIDIHDR pmh,
_In_ UINT cbmh);
MMRESULT WINAPI midiInStart(_In_ HMIDIIN);
MMRESULT WINAPI midiInStop(_In_ HMIDIIN);
MMRESULT WINAPI midiInReset(_In_ HMIDIIN);
MMRESULT WINAPI midiInGetID(_In_ HMIDIIN, _Out_ LPUINT);
#if (WINVER >= 0x030a)
#ifdef _WIN32
MMRESULT WINAPI midiInMessage(HMIDIIN,UINT,DWORD_PTR,DWORD_PTR);
MMRESULT WINAPI midiInMessage(_In_opt_ HMIDIIN, _In_ UINT, _In_opt_ DWORD_PTR, _In_opt_ DWORD_PTR);
#else
DWORD WINAPI midiInMessage(HMIDIIN,UINT,DWORD,DWORD);
#endif
#endif
UINT WINAPI auxGetNumDevs(void);
MMRESULT WINAPI auxGetDevCapsA(UINT_PTR,LPAUXCAPSA,UINT);
MMRESULT WINAPI auxGetDevCapsW(UINT_PTR,LPAUXCAPSW,UINT);
MMRESULT WINAPI auxSetVolume(UINT,DWORD);
MMRESULT WINAPI auxGetVolume(UINT,PDWORD);
MMRESULT WINAPI auxOutMessage(UINT,UINT,DWORD_PTR,DWORD_PTR);
MMRESULT
WINAPI
auxGetDevCapsA(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbac) LPAUXCAPSA pac,
_In_ UINT cbac);
MMRESULT
WINAPI
auxGetDevCapsW(
_In_ UINT_PTR uDeviceID,
_Out_writes_bytes_(cbac) LPAUXCAPSW pac,
_In_ UINT cbac);
MMRESULT WINAPI auxSetVolume(_In_ UINT, _In_ DWORD);
MMRESULT WINAPI auxGetVolume(_In_ UINT, _Out_ PDWORD);
MMRESULT
WINAPI
auxOutMessage(
_In_ UINT,
_In_ UINT,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR);
UINT WINAPI mixerGetNumDevs(void);
MMRESULT WINAPI mixerGetDevCapsA(UINT_PTR,LPMIXERCAPSA,UINT);
MMRESULT WINAPI mixerGetDevCapsW(UINT_PTR,LPMIXERCAPSW,UINT);
MMRESULT WINAPI mixerOpen(LPHMIXER,UINT,DWORD_PTR,DWORD_PTR,DWORD);
MMRESULT WINAPI mixerClose(HMIXER);
DWORD WINAPI mixerMessage(HMIXER,UINT,DWORD_PTR,DWORD_PTR);
MMRESULT WINAPI mixerGetLineInfoA(HMIXEROBJ,LPMIXERLINEA,DWORD);
MMRESULT WINAPI mixerGetLineInfoW(HMIXEROBJ,LPMIXERLINEW,DWORD);
MMRESULT WINAPI mixerGetID(HMIXEROBJ,PUINT,DWORD);
MMRESULT WINAPI mixerGetLineControlsA(HMIXEROBJ,LPMIXERLINECONTROLSA,DWORD);
MMRESULT WINAPI mixerGetLineControlsW(HMIXEROBJ,LPMIXERLINECONTROLSW,DWORD);
MMRESULT WINAPI mixerGetControlDetailsA(HMIXEROBJ,LPMIXERCONTROLDETAILS,DWORD);
MMRESULT WINAPI mixerGetControlDetailsW(HMIXEROBJ,LPMIXERCONTROLDETAILS,DWORD);
MMRESULT WINAPI mixerSetControlDetails(HMIXEROBJ,LPMIXERCONTROLDETAILS,DWORD);
MMRESULT WINAPI timeGetSystemTime(LPMMTIME,UINT);
MMRESULT
WINAPI
mixerGetDevCapsA(
_In_ UINT_PTR uMxId,
_Out_writes_bytes_(cbmxcaps) LPMIXERCAPSA pmxcaps,
_In_ UINT cbmxcaps);
MMRESULT
WINAPI
mixerGetDevCapsW(
_In_ UINT_PTR uMxId,
_Out_writes_bytes_(cbmxcaps) LPMIXERCAPSW pmxcaps,
_In_ UINT cbmxcaps);
MMRESULT
WINAPI
mixerOpen(
_Out_opt_ LPHMIXER,
_In_ UINT,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR,
_In_ DWORD);
MMRESULT WINAPI mixerClose(_In_ HMIXER);
DWORD
WINAPI
mixerMessage(
_In_opt_ HMIXER,
_In_ UINT,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR);
MMRESULT
WINAPI
mixerGetLineInfoA(
_In_opt_ HMIXEROBJ,
_Inout_ LPMIXERLINEA,
_In_ DWORD);
MMRESULT
WINAPI
mixerGetLineInfoW(
_In_opt_ HMIXEROBJ,
_Inout_ LPMIXERLINEW,
_In_ DWORD);
MMRESULT WINAPI mixerGetID(_In_opt_ HMIXEROBJ, _Out_ PUINT, _In_ DWORD);
MMRESULT
WINAPI
mixerGetLineControlsA(
_In_opt_ HMIXEROBJ,
_Inout_ LPMIXERLINECONTROLSA,
_In_ DWORD);
MMRESULT
WINAPI
mixerGetLineControlsW(
_In_opt_ HMIXEROBJ,
_Inout_ LPMIXERLINECONTROLSW,
_In_ DWORD);
MMRESULT
WINAPI
mixerGetControlDetailsA(
_In_opt_ HMIXEROBJ,
_Inout_ LPMIXERCONTROLDETAILS,
_In_ DWORD);
MMRESULT
WINAPI
mixerGetControlDetailsW(
_In_opt_ HMIXEROBJ,
_Inout_ LPMIXERCONTROLDETAILS,
_In_ DWORD);
MMRESULT
WINAPI
mixerSetControlDetails(
_In_opt_ HMIXEROBJ,
_In_ LPMIXERCONTROLDETAILS,
_In_ DWORD);
MMRESULT
WINAPI
timeGetSystemTime(
_Out_writes_bytes_(cbmmt) LPMMTIME pmmt,
_In_ UINT cbmmt);
DWORD WINAPI timeGetTime(void);
MMRESULT WINAPI timeSetEvent(UINT,UINT,LPTIMECALLBACK,DWORD_PTR,UINT);
MMRESULT WINAPI timeKillEvent(UINT);
MMRESULT WINAPI timeGetDevCaps(LPTIMECAPS,UINT);
MMRESULT WINAPI timeBeginPeriod(UINT);
MMRESULT WINAPI timeEndPeriod(UINT);
MMRESULT
WINAPI
timeSetEvent(
_In_ UINT,
_In_ UINT,
_In_ LPTIMECALLBACK,
_In_ DWORD_PTR,
_In_ UINT);
MMRESULT WINAPI timeKillEvent(_In_ UINT);
MMRESULT
WINAPI
timeGetDevCaps(
_Out_writes_bytes_(cbtc) LPTIMECAPS ptc,
_In_ UINT cbtc);
MMRESULT WINAPI timeBeginPeriod(_In_ UINT);
MMRESULT WINAPI timeEndPeriod(_In_ UINT);
UINT WINAPI joyGetNumDevs(void);
MMRESULT WINAPI joyGetDevCapsA(UINT_PTR,LPJOYCAPSA,UINT);
MMRESULT WINAPI joyGetDevCapsW(UINT_PTR,LPJOYCAPSW,UINT);
MMRESULT WINAPI joyGetPos(UINT,LPJOYINFO);
MMRESULT WINAPI joyGetPosEx(UINT,LPJOYINFOEX);
MMRESULT WINAPI joyGetThreshold(UINT,LPUINT);
MMRESULT WINAPI joyReleaseCapture(UINT);
MMRESULT WINAPI joySetCapture(HWND,UINT,UINT,BOOL);
MMRESULT WINAPI joySetThreshold(UINT,UINT);
FOURCC WINAPI mmioStringToFOURCCA(LPCSTR,UINT);
FOURCC WINAPI mmioStringToFOURCCW(LPCWSTR,UINT);
LPMMIOPROC WINAPI mmioInstallIOProcA(FOURCC,LPMMIOPROC,DWORD);
LPMMIOPROC WINAPI mmioInstallIOProcW(FOURCC,LPMMIOPROC,DWORD);
HMMIO WINAPI mmioOpenA(LPSTR,LPMMIOINFO,DWORD);
HMMIO WINAPI mmioOpenW(LPWSTR,LPMMIOINFO,DWORD);
MMRESULT WINAPI mmioRenameA(LPCSTR,LPCSTR,LPCMMIOINFO,DWORD);
MMRESULT WINAPI mmioRenameW(LPCWSTR,LPCWSTR,LPCMMIOINFO,DWORD);
MMRESULT WINAPI mmioClose(HMMIO,UINT);
LONG WINAPI mmioRead(HMMIO,HPSTR,LONG);
LONG WINAPI mmioWrite(HMMIO,LPCSTR,LONG);
LONG WINAPI mmioSeek(HMMIO,LONG,int);
MMRESULT WINAPI mmioGetInfo(HMMIO,LPMMIOINFO,UINT);
MMRESULT WINAPI mmioSetInfo(HMMIO,LPCMMIOINFO,UINT);
MMRESULT WINAPI mmioSetBuffer(HMMIO,LPSTR,LONG,UINT);
MMRESULT WINAPI mmioFlush(HMMIO,UINT);
MMRESULT WINAPI mmioAdvance(HMMIO,LPMMIOINFO,UINT);
LRESULT WINAPI mmioSendMessage(HMMIO,UINT,LPARAM,LPARAM);
MMRESULT WINAPI mmioDescend(HMMIO,LPMMCKINFO,const MMCKINFO*,UINT);
MMRESULT WINAPI mmioAscend(HMMIO,LPMMCKINFO,UINT);
MMRESULT WINAPI mmioCreateChunk(HMMIO,LPMMCKINFO,UINT);
MCIERROR WINAPI mciSendCommandA(MCIDEVICEID,UINT,DWORD_PTR,DWORD_PTR);
MCIERROR WINAPI mciSendCommandW(MCIDEVICEID,UINT,DWORD_PTR,DWORD_PTR);
MCIERROR WINAPI mciSendStringA(LPCSTR,LPSTR,UINT,HWND);
MCIERROR WINAPI mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND);
MCIDEVICEID WINAPI mciGetDeviceIDA(LPCSTR);
MCIDEVICEID WINAPI mciGetDeviceIDW(LPCWSTR);
MCIDEVICEID WINAPI mciGetDeviceIDFromElementIDA(DWORD,LPCSTR);
MCIDEVICEID WINAPI mciGetDeviceIDFromElementIDW(DWORD,LPCWSTR);
BOOL WINAPI mciGetErrorStringA(MCIERROR,LPSTR,UINT);
BOOL WINAPI mciGetErrorStringW(MCIERROR,LPWSTR,UINT);
BOOL WINAPI mciSetYieldProc(MCIDEVICEID,YIELDPROC,DWORD);
HTASK WINAPI mciGetCreatorTask(MCIDEVICEID);
YIELDPROC WINAPI mciGetYieldProc(MCIDEVICEID,PDWORD);
MMRESULT
WINAPI
joyGetDevCapsA(
_In_ UINT_PTR uJoyID,
_Out_writes_bytes_(cbjc) LPJOYCAPSA pjc,
_In_ UINT cbjc);
MMRESULT
WINAPI
joyGetDevCapsW(
_In_ UINT_PTR uJoyID,
_Out_writes_bytes_(cbjc) LPJOYCAPSW pjc,
_In_ UINT cbjc);
MMRESULT WINAPI joyGetPos(_In_ UINT, _Out_ LPJOYINFO);
MMRESULT WINAPI joyGetPosEx(_In_ UINT, _Out_ LPJOYINFOEX);
MMRESULT WINAPI joyGetThreshold(_In_ UINT, _Out_ LPUINT);
MMRESULT WINAPI joyReleaseCapture(_In_ UINT);
MMRESULT WINAPI joySetCapture(_In_ HWND, _In_ UINT, _In_ UINT, _In_ BOOL);
MMRESULT WINAPI joySetThreshold(_In_ UINT, _In_ UINT);
FOURCC WINAPI mmioStringToFOURCCA(LPCSTR, _In_ UINT);
FOURCC WINAPI mmioStringToFOURCCW(LPCWSTR, _In_ UINT);
LPMMIOPROC
WINAPI
mmioInstallIOProcA(
_In_ FOURCC,
_In_opt_ LPMMIOPROC,
_In_ DWORD);
LPMMIOPROC
WINAPI
mmioInstallIOProcW(
_In_ FOURCC,
_In_opt_ LPMMIOPROC,
_In_ DWORD);
HMMIO
WINAPI
mmioOpenA(
_Inout_updates_bytes_opt_(128) LPSTR pszFileName,
_Inout_opt_ LPMMIOINFO pmmioinfo,
_In_ DWORD fdwOpen);
HMMIO
WINAPI
mmioOpenW(
_Inout_updates_bytes_opt_(128) LPWSTR pszFileName,
_Inout_opt_ LPMMIOINFO pmmioinfo,
_In_ DWORD fdwOpen);
MMRESULT
WINAPI
mmioRenameA(
_In_ LPCSTR,
_In_ LPCSTR,
_In_opt_ LPCMMIOINFO,
_In_ DWORD);
MMRESULT
WINAPI
mmioRenameW(
_In_ LPCWSTR,
_In_ LPCWSTR,
_In_opt_ LPCMMIOINFO,
_In_ DWORD);
MMRESULT WINAPI mmioClose(_In_ HMMIO, _In_ UINT);
LONG
WINAPI
mmioRead(
_In_ HMMIO hmmio,
_Out_writes_bytes_(cch) HPSTR pch,
_In_ LONG cch);
LONG
WINAPI
mmioWrite(
_In_ HMMIO hmmio,
_In_reads_bytes_(cch) const char _huge * pch,
_In_ LONG cch);
LONG WINAPI mmioSeek(_In_ HMMIO, _In_ LONG, _In_ int);
MMRESULT WINAPI mmioGetInfo(_In_ HMMIO, _Out_ LPMMIOINFO, _In_ UINT);
MMRESULT WINAPI mmioSetInfo(_In_ HMMIO, _In_ LPCMMIOINFO, _In_ UINT);
MMRESULT
WINAPI
mmioSetBuffer(
_In_ HMMIO hmmio,
_Out_writes_opt_(cchBuffer) LPSTR pchBuffer,
_In_ LONG cchBuffer,
_In_ UINT fuBuffer);
MMRESULT WINAPI mmioFlush(_In_ HMMIO, _In_ UINT);
MMRESULT WINAPI mmioAdvance(_In_ HMMIO, _In_opt_ LPMMIOINFO, _In_ UINT);
LRESULT
WINAPI
mmioSendMessage(
_In_ HMMIO,
_In_ UINT,
_In_opt_ LPARAM,
_In_opt_ LPARAM);
MMRESULT
WINAPI
mmioDescend(
_In_ HMMIO,
_Inout_ LPMMCKINFO,
_In_opt_ const MMCKINFO*,
_In_ UINT);
MMRESULT WINAPI mmioAscend(_In_ HMMIO, _In_ LPMMCKINFO, _In_ UINT);
MMRESULT WINAPI mmioCreateChunk(_In_ HMMIO, _In_ LPMMCKINFO, _In_ UINT);
MCIERROR
WINAPI
mciSendCommandA(
_In_ MCIDEVICEID,
_In_ UINT,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR);
MCIERROR
WINAPI
mciSendCommandW(
_In_ MCIDEVICEID,
_In_ UINT,
_In_opt_ DWORD_PTR,
_In_opt_ DWORD_PTR);
MCIERROR
WINAPI
mciSendStringA(
_In_ LPCSTR lpstrCommand,
_Out_writes_opt_(uReturnLength) LPSTR lpstrReturnString,
_In_ UINT uReturnLength,
_In_opt_ HWND hwndCallback);
MCIERROR
WINAPI
mciSendStringW(
_In_ LPCWSTR lpstrCommand,
_Out_writes_opt_(uReturnLength) LPWSTR lpstrReturnString,
_In_ UINT uReturnLength,
_In_opt_ HWND hwndCallback);
MCIDEVICEID WINAPI mciGetDeviceIDA(_In_ LPCSTR);
MCIDEVICEID WINAPI mciGetDeviceIDW(_In_ LPCWSTR);
MCIDEVICEID WINAPI mciGetDeviceIDFromElementIDA(_In_ DWORD, _In_ LPCSTR);
MCIDEVICEID WINAPI mciGetDeviceIDFromElementIDW(_In_ DWORD, _In_ LPCWSTR);
BOOL
WINAPI
mciGetErrorStringA(
_In_ MCIERROR mcierr,
_Out_writes_(cchText) LPSTR pszText,
_In_ UINT cchText);
BOOL
WINAPI
mciGetErrorStringW(
_In_ MCIERROR mcierr,
_Out_writes_(cchText) LPWSTR pszText,
_In_ UINT cchText);
BOOL WINAPI mciSetYieldProc(_In_ MCIDEVICEID, _In_opt_ YIELDPROC, _In_ DWORD);
HTASK WINAPI mciGetCreatorTask(_In_ MCIDEVICEID);
YIELDPROC WINAPI mciGetYieldProc(_In_ MCIDEVICEID, _In_ PDWORD);
#ifdef _WINE
DWORD WINAPI GetDriverFlags(HDRVR hDriver);

File diff suppressed because it is too large Load diff

View file

@ -473,6 +473,8 @@ BOOL WINAPI SetConsoleMenuClose(_In_ BOOL);
BOOL WINAPI SetConsoleCursor(_In_ HANDLE, _In_ HCURSOR);
/* Undocumented, see http://undoc.airesoft.co.uk/kernel32.dll/ShowConsoleCursor.php */
INT WINAPI ShowConsoleCursor(_In_ HANDLE, _In_ BOOL);
/* Undocumented, see http://comments.gmane.org/gmane.comp.lang.harbour.devel/27844 */
BOOL WINAPI SetConsolePalette(_In_ HANDLE, _In_ HPALETTE, _In_ UINT);
BOOL WINAPI WriteConsoleA(HANDLE,CONST VOID*,DWORD,LPDWORD,LPVOID);
BOOL WINAPI WriteConsoleW(HANDLE,CONST VOID*,DWORD,LPDWORD,LPVOID);

View file

@ -824,7 +824,6 @@ int WINAPI GetTimeFormatA(LCID,DWORD,const SYSTEMTIME*,LPCSTR,LPSTR,int);
int WINAPI GetTimeFormatW(LCID,DWORD,const SYSTEMTIME*,LPCWSTR,LPWSTR,int);
LANGID WINAPI GetUserDefaultLangID(void);
LCID WINAPI GetUserDefaultLCID(void);
LANGID WINAPI GetUserDefaultUILanguage(void);
GEOID WINAPI GetUserGeoID(_In_ GEOCLASS);
BOOL WINAPI IsDBCSLeadByte(_In_ BYTE);
BOOL WINAPI IsDBCSLeadByteEx(_In_ UINT, _In_ BYTE);

View file

@ -65,7 +65,7 @@ typedef enum _CONSRV_API_NUMBER
ConsolepSetCursor,
ConsolepShowCursor,
ConsolepMenuControl,
// ConsolepSetPalette,
ConsolepSetPalette,
ConsolepSetDisplayMode,
// ConsolepRegisterVDM,
ConsolepGetHardwareState,
@ -303,6 +303,13 @@ typedef struct
SMALL_RECT Region;
} CONSOLE_INVALIDATEDIBITS, *PCONSOLE_INVALIDATEDIBITS;
typedef struct
{
HANDLE OutputHandle;
HPALETTE PaletteHandle;
UINT Usage;
} CONSOLE_SETPALETTE, *PCONSOLE_SETPALETTE;
typedef struct
{
DWORD Length;
@ -664,6 +671,7 @@ typedef struct _CONSOLE_API_MESSAGE
/* Console window */
CONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest;
CONSOLE_SETPALETTE SetPaletteRequest;
CONSOLE_GETSETCONSOLETITLE TitleRequest;
CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest;
CONSOLE_MENUCONTROL MenuControlRequest;

View file

@ -24,6 +24,8 @@ BOOLEAN IpWorkItemQueued = FALSE;
IP_PROTOCOL_HANDLER ProtocolTable[IP_PROTOCOL_TABLE_SIZE];
ULONG IpTimerExpirations;
VOID
TCPRegisterInterface(PIP_INTERFACE IF);
@ -119,9 +121,16 @@ VOID NTAPI IPTimeoutDpcFn(PKDPC Dpc,
* SystemArgument1 = Unused
* SystemArgument2 = Unused
* NOTES:
* This routine is dispatched once in a while to do maintainance jobs
* This routine is dispatched once in a while to do maintenance jobs
*/
{
IpTimerExpirations++;
if ((IpTimerExpirations % 10) == 0)
{
LogActiveObjects();
}
/* Check if datagram fragments have taken too long to assemble */
IPDatagramReassemblyTimeout();

View file

@ -444,8 +444,6 @@ PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
TcpipAcquireSpinLock(&NeighborCache[HashValue].Lock, &OldIrql);
NCE = NeighborCache[HashValue].Cache;
/* If there's no adapter specified, we'll look for a match on
* each one. */
if (Interface == NULL)
@ -460,6 +458,7 @@ PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
do
{
NCE = NeighborCache[HashValue].Cache;
while (NCE != NULL)
{
if (NCE->Interface == Interface &&
@ -477,6 +476,21 @@ PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
while ((FirstInterface != NULL) &&
((Interface = GetDefaultInterface()) != FirstInterface));
if ((NCE == NULL) && (FirstInterface != NULL))
{
/* This time we'll even match loopback NCEs */
NCE = NeighborCache[HashValue].Cache;
while (NCE != NULL)
{
if (AddrIsEqual(Address, &NCE->Address))
{
break;
}
NCE = NCE->Next;
}
}
TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));

View file

@ -264,12 +264,10 @@ TCPFinEventHandler(void *arg, const err_t err)
const NTSTATUS Status = TCPTranslateError(err);
KIRQL OldIrql;
ASSERT(Connection->SocketContext == NULL);
ASSERT(Connection->AddressFile);
ASSERT(err != ERR_OK);
/* First off all, remove the PCB pointer */
Connection->SocketContext = NULL;
/* Complete all outstanding requests now */
FlushAllQueues(Connection, Status);

View file

@ -35,6 +35,21 @@ extern NPAGED_LOOKASIDE_LIST QueueEntryLookasideList;
/* Required for ERR_T to NTSTATUS translation in receive error handling */
NTSTATUS TCPTranslateError(const err_t err);
void
LibTCPDumpPcb(PVOID SocketContext)
{
struct tcp_pcb *pcb = (struct tcp_pcb*)SocketContext;
unsigned int addr = ntohl(pcb->remote_ip.addr);
DbgPrint("\tState: %s\n", tcp_state_str[pcb->state]);
DbgPrint("\tRemote: (%d.%d.%d.%d, %d)\n",
(addr >> 24) & 0xFF,
(addr >> 16) & 0xFF,
(addr >> 8) & 0xFF,
addr & 0xFF,
pcb->remote_port);
}
static
void
LibTCPEmptyQueue(PCONNECTION_ENDPOINT Connection)
@ -231,17 +246,20 @@ InternalRecvEventHandler(void *arg, PTCP_PCB pcb, struct pbuf *p, const err_t er
Connection->ReceiveShutdown = TRUE;
Connection->ReceiveShutdownStatus = STATUS_SUCCESS;
/* This code path executes for both remotely and locally initiated closures,
* and we need to distinguish between them */
if (Connection->SocketContext)
/* If we already did a send shutdown, we're in TIME_WAIT so we can't use this PCB anymore */
if (Connection->SendShutdown)
{
/* Remotely initiated close */
TCPRecvEventHandler(arg);
Connection->SocketContext = NULL;
tcp_arg(pcb, NULL);
}
else
/* Indicate the graceful close event */
TCPRecvEventHandler(arg);
/* If the PCB is gone, clean up the connection */
if (Connection->SendShutdown)
{
/* Locally initated close */
TCPFinEventHandler(arg, ERR_CLSD);
TCPFinEventHandler(Connection, ERR_CLSD);
}
}
@ -285,30 +303,20 @@ void
InternalErrorEventHandler(void *arg, const err_t err)
{
PCONNECTION_ENDPOINT Connection = arg;
KIRQL OldIrql;
/* Make sure the socket didn't get closed */
if (!arg) return;
if (!arg || Connection->SocketContext == NULL) return;
/* Check if data is left to be read */
LockObject(Connection, &OldIrql);
if (IsListEmpty(&Connection->PacketQueue))
{
UnlockObject(Connection, OldIrql);
/* The PCB is dead now */
Connection->SocketContext = NULL;
/* Deliver the error now */
TCPFinEventHandler(arg, err);
}
else
{
UnlockObject(Connection, OldIrql);
/* Give them one shot to receive the remaining data */
Connection->ReceiveShutdown = TRUE;
Connection->ReceiveShutdownStatus = TCPTranslateError(err);
TCPRecvEventHandler(Connection);
/* Defer the error delivery until all data is gone */
Connection->ReceiveShutdown = TRUE;
Connection->ReceiveShutdownStatus = TCPTranslateError(err);
TCPRecvEventHandler(arg);
}
/* Terminate the connection */
TCPFinEventHandler(Connection, err);
}
static
@ -633,7 +641,12 @@ LibTCPShutdownCallback(void *arg)
goto done;
}
/* These need to be called separately, otherwise we get a tcp_close() */
/* LwIP makes the (questionable) assumption that SHUTDOWN_RDWR is equivalent to tcp_close().
* This assumption holds even if the shutdown calls are done separately (even through multiple
* WinSock shutdown() calls). This assumption means that lwIP has the right to deallocate our
* PCB without telling us if we shutdown TX and RX. To avoid these problems, we'll clear the
* socket context if we have called shutdown for TX and RX.
*/
if (msg->Input.Shutdown.shut_rx) {
msg->Output.Shutdown.Error = tcp_shutdown(pcb, TRUE, FALSE);
}
@ -651,6 +664,15 @@ LibTCPShutdownCallback(void *arg)
if (msg->Input.Shutdown.shut_tx)
msg->Input.Shutdown.Connection->SendShutdown = TRUE;
if (msg->Input.Shutdown.Connection->ReceiveShutdown &&
msg->Input.Shutdown.Connection->SendShutdown)
{
/* The PCB is not ours anymore */
msg->Input.Shutdown.Connection->SocketContext = NULL;
tcp_arg(pcb, NULL);
TCPFinEventHandler(msg->Input.Shutdown.Connection, ERR_CLSD);
}
}
done:
@ -697,37 +719,41 @@ LibTCPCloseCallback(void *arg)
/* Empty the queue even if we're already "closed" */
LibTCPEmptyQueue(msg->Input.Close.Connection);
/* Check if we've already been closed */
if (msg->Input.Close.Connection->Closing)
{
msg->Output.Close.Error = ERR_OK;
goto done;
}
/* Enter "closing" mode if we're doing a normal close */
if (msg->Input.Close.Callback)
msg->Input.Close.Connection->Closing = TRUE;
/* Check if the PCB was already "closed" but the client doesn't know it yet */
if (!msg->Input.Close.Connection->SocketContext)
{
msg->Output.Close.Error = ERR_OK;
goto done;
}
/* Clear the PCB pointer */
/* Clear the PCB pointer and stop callbacks */
msg->Input.Close.Connection->SocketContext = NULL;
tcp_arg(pcb, NULL);
switch (pcb->state)
{
case CLOSED:
case LISTEN:
case SYN_SENT:
msg->Output.Close.Error = tcp_close(pcb);
if (!msg->Output.Close.Error && msg->Input.Close.Callback)
TCPFinEventHandler(msg->Input.Close.Connection, ERR_CLSD);
break;
default:
/* Abort the socket */
tcp_abort(pcb);
msg->Output.Close.Error = ERR_OK;
break;
}
/* This may generate additional callbacks but we don't care,
* because they're too inconsistent to rely on */
msg->Output.Close.Error = tcp_close(pcb);
if (msg->Output.Close.Error)
{
/* Restore the PCB pointer */
msg->Input.Close.Connection->SocketContext = pcb;
msg->Input.Close.Connection->Closing = FALSE;
}
else if (msg->Input.Close.Callback)
{
TCPFinEventHandler(msg->Input.Close.Connection, ERR_CLSD);
}
done:

View file

@ -19,6 +19,6 @@ list(APPEND SOURCE
add_executable(ntvdm ${SOURCE})
set_module_type(ntvdm win32cui UNICODE)
target_link_libraries(ntvdm softx86 softx87)
add_importlibs(ntvdm msvcrt user32 kernel32 ntdll)
add_importlibs(ntvdm msvcrt user32 gdi32 kernel32 ntdll)
add_dependencies(ntvdm softx86 softx87)
add_cd_file(TARGET ntvdm DESTINATION reactos/system32 FOR all)

View file

@ -408,7 +408,12 @@ BOOLEAN BiosInitialize(VOID)
}
/* Initialize VGA */
VgaInitialize(BiosConsoleOutput);
if (!VgaInitialize(BiosConsoleOutput))
{
CloseHandle(BiosConsoleOutput);
CloseHandle(BiosConsoleInput);
return FALSE;
}
/* Update the cursor position */
BiosSetCursorPosition(BiosSavedBufferInfo.dwCursorPosition.Y,

View file

@ -18,6 +18,42 @@
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
static CONST DWORD MemoryLimit[] = { 0xAFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
static CONST COLORREF VgaDefaultPalette[VGA_MAX_COLORS] =
{
0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, 0xAA0000, 0xAA00AA, 0xAA5500, 0xAAAAAA,
0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF,
0x000000, 0x101010, 0x202020, 0x353535, 0x454545, 0x555555, 0x656565, 0x757575,
0x8A8A8A, 0x9A9A9A, 0xAAAAAA, 0xBABABA, 0xCACACA, 0xDFDFDF, 0xEFEFEF, 0xFFFFFF,
0x0000FF, 0x4100FF, 0x8200FF, 0xBE00FF, 0xFF00FF, 0xFF00BE, 0xFF0082, 0xFF0041,
0xFF0000, 0xFF4100, 0xFF8200, 0xFFBE00, 0xFFFF00, 0xBEFF00, 0x82FF00, 0x41FF00,
0x00FF00, 0x00FF41, 0x00FF82, 0x00FFBE, 0x00FFFF, 0x00BEFF, 0x0082FF, 0x0041FF,
0x8282FF, 0x9E82FF, 0xBE82FF, 0xDF82FF, 0xFF82FF, 0xFF82DF, 0xFF82BE, 0xFF829E,
0xFF8282, 0xFF9E82, 0xFFBE82, 0xFFDF82, 0xFFFF82, 0xDFFF82, 0xBEFF82, 0x9EFF82,
0x82FF82, 0x82FF9E, 0x82FFBE, 0x82FFDF, 0x82FFFF, 0x82DFFF, 0x82BEFF, 0x829EFF,
0xBABAFF, 0xCABAFF, 0xDFBAFF, 0xEFBAFF, 0xFFBAFF, 0xFFBAEF, 0xFFBADF, 0xFFBACA,
0xFFBABA, 0xFFCABA, 0xFFDFBA, 0xFFEFBA, 0xFFFFBA, 0xEFFFBA, 0xDFFFBA, 0xCAFFBA,
0xBAFFBA, 0xBAFFCA, 0xBAFFDF, 0xBAFFEF, 0xBAFFFF, 0xBAEFFF, 0xBADFFF, 0xBACAFF,
0x000071, 0x1C0071, 0x390071, 0x550071, 0x710071, 0x710055, 0x710039, 0x71001C,
0x710000, 0x711C00, 0x713900, 0x715500, 0x717100, 0x557100, 0x397100, 0x1C7100,
0x007100, 0x00711C, 0x007139, 0x007155, 0x007171, 0x005571, 0x003971, 0x001C71,
0x393971, 0x453971, 0x553971, 0x613971, 0x713971, 0x713961, 0x713955, 0x713945,
0x713939, 0x714539, 0x715539, 0x716139, 0x717139, 0x617139, 0x557139, 0x457139,
0x397139, 0x397145, 0x397155, 0x397161, 0x397171, 0x396171, 0x395571, 0x394571,
0x515171, 0x595171, 0x615171, 0x695171, 0x715171, 0x715169, 0x715161, 0x715159,
0x715151, 0x715951, 0x716151, 0x716951, 0x717151, 0x697151, 0x617151, 0x597151,
0x517151, 0x517159, 0x517161, 0x517169, 0x517171, 0x516971, 0x516171, 0x515971,
0x000041, 0x100041, 0x200041, 0x310041, 0x410041, 0x410031, 0x410020, 0x410010,
0x410000, 0x411000, 0x412000, 0x413100, 0x414100, 0x314100, 0x204100, 0x104100,
0x004100, 0x004110, 0x004120, 0x004131, 0x004141, 0x003141, 0x002041, 0x001041,
0x202041, 0x282041, 0x312041, 0x392041, 0x412041, 0x412039, 0x412031, 0x412028,
0x412020, 0x412820, 0x413120, 0x413920, 0x414120, 0x394120, 0x314120, 0x284120,
0x204120, 0x204128, 0x204131, 0x204139, 0x204141, 0x203941, 0x203141, 0x202841,
0x2D2D41, 0x312D41, 0x352D41, 0x3D2D41, 0x412D41, 0x412D3D, 0x412D35, 0x412D31,
0x412D2D, 0x41312D, 0x41352D, 0x413D2D, 0x41412D, 0x3D412D, 0x35412D, 0x31412D,
0x2D412D, 0x2D4131, 0x2D4135, 0x2D413D, 0x2D4141, 0x2D3D41, 0x2D3541, 0x2D3141,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
};
static BYTE VgaMemory[VGA_NUM_BANKS * VGA_BANK_SIZE];
static BYTE VgaLatchRegisters[VGA_NUM_BANKS] = {0, 0, 0, 0};
static BYTE VgaMiscRegister;
@ -33,6 +69,7 @@ static BYTE VgaAcRegisters[VGA_AC_MAX_REG];
static BYTE VgaDacIndex = 0;
static BOOLEAN VgaDacReadWrite = FALSE;
static BYTE VgaDacRegisters[VGA_PALETTE_SIZE];
static HPALETTE PaletteHandle = NULL;
static BOOLEAN InVerticalRetrace = FALSE;
static BOOLEAN InHorizontalRetrace = FALSE;
static HANDLE TextConsoleBuffer = NULL;
@ -42,6 +79,7 @@ static HANDLE ConsoleMutex = NULL;
static BOOLEAN NeedsUpdate = FALSE;
static BOOLEAN ModeChanged = TRUE;
static BOOLEAN CursorMoved = FALSE;
static BOOLEAN PaletteChanged = FALSE;
static BOOLEAN TextMode = TRUE;
static SMALL_RECT UpdateRectangle = { 0, 0, 0, 0 };
@ -262,11 +300,30 @@ static VOID VgaWriteCrtc(BYTE Data)
static VOID VgaWriteDac(BYTE Data)
{
/* Set the value */
VgaDacRegisters[VgaDacIndex++] = Data;
VgaDacIndex %= VGA_PALETTE_SIZE;
INT PaletteIndex;
PALETTEENTRY Entry;
// TODO: Change the palette!
/* Set the value */
VgaDacRegisters[VgaDacIndex] = Data;
/* Find the palette index */
PaletteIndex = VgaDacIndex / 3;
/* Fill the entry structure */
Entry.peRed = VGA_DAC_TO_COLOR(VgaDacRegisters[PaletteIndex * 3]);
Entry.peGreen = VGA_DAC_TO_COLOR(VgaDacRegisters[PaletteIndex * 3 + 1]);
Entry.peBlue = VGA_DAC_TO_COLOR(VgaDacRegisters[PaletteIndex * 3 + 2]);
Entry.peFlags = 0;
/* Update the palette entry */
SetPaletteEntries(PaletteHandle, PaletteIndex, 1, &Entry);
/* Set the palette changed flag */
PaletteChanged = TRUE;
/* Update the index */
VgaDacIndex++;
VgaDacIndex %= VGA_PALETTE_SIZE;
}
static VOID VgaWriteAc(BYTE Data)
@ -397,6 +454,11 @@ static VOID VgaUpdateMode(VOID)
/* Clear the text mode flag */
TextMode = FALSE;
/* Set the palette */
SetConsolePalette(GraphicsConsoleBuffer,
PaletteHandle,
SYSPAL_NOSTATIC256);
}
/* Perform a full update */
@ -691,6 +753,19 @@ VOID VgaRefreshDisplay(VOID)
CursorMoved = FALSE;
}
if (PaletteChanged)
{
if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_NOALPHA)
{
/* Set the graphics mode palette */
SetConsolePalette(GraphicsConsoleBuffer,
PaletteHandle,
SYSPAL_NOSTATIC256);
}
PaletteChanged = FALSE;
}
/* Update the contents of the framebuffer */
VgaUpdateFramebuffer();
@ -1026,7 +1101,7 @@ VOID VgaClearMemory(VOID)
ZeroMemory(VgaMemory, sizeof(VgaMemory));
}
VOID VgaInitialize(HANDLE TextHandle)
BOOLEAN VgaInitialize(HANDLE TextHandle)
{
INT i, j;
COORD Resolution;
@ -1037,6 +1112,7 @@ VOID VgaInitialize(HANDLE TextHandle)
PCHAR_INFO CharBuffer;
DWORD Address = 0;
DWORD CurrentAddr;
LPLOGPALETTE Palette;
/* Set the global handle */
TextConsoleBuffer = TextHandle;
@ -1083,6 +1159,40 @@ VOID VgaInitialize(HANDLE TextHandle)
/* Move to the next scanline */
Address += ScanlineSize;
}
/* Allocate storage space for the palette */
Palette = (LPLOGPALETTE)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(LOGPALETTE)
+ VGA_MAX_COLORS * sizeof(PALETTEENTRY));
if (Palette == NULL) return FALSE;
/* Initialize the palette */
Palette->palVersion = 0x0100;
Palette->palNumEntries = VGA_MAX_COLORS;
/* Copy the colors of the default palette to the DAC and console palette */
for (i = 0; i < VGA_MAX_COLORS; i++)
{
/* Set the palette entries */
Palette->palPalEntry[i].peRed = GetRValue(VgaDefaultPalette[i]);
Palette->palPalEntry[i].peGreen = GetGValue(VgaDefaultPalette[i]);
Palette->palPalEntry[i].peBlue = GetBValue(VgaDefaultPalette[i]);
/* Set the DAC registers */
VgaDacRegisters[i * 3] = VGA_COLOR_TO_DAC(GetRValue(VgaDefaultPalette[i]));
VgaDacRegisters[i * 3 + 1] = VGA_COLOR_TO_DAC(GetGValue(VgaDefaultPalette[i]));
VgaDacRegisters[i * 3 + 2] = VGA_COLOR_TO_DAC(GetBValue(VgaDefaultPalette[i]));
}
/* Create the palette */
PaletteHandle = CreatePalette(Palette);
/* Free the palette */
HeapFree(GetProcessHeap(), 0, Palette);
/* Return success */
return TRUE;
}
/* EOF */

View file

@ -35,8 +35,11 @@
#define VGA_NUM_BANKS 4
#define VGA_BANK_SIZE 0x10000
#define VGA_PALETTE_SIZE 768
#define VGA_MAX_COLORS 256
#define VGA_PALETTE_SIZE (VGA_MAX_COLORS * 3)
#define VGA_BITMAP_INFO_SIZE (sizeof(BITMAPINFOHEADER) + 2 * (VGA_PALETTE_SIZE / 3))
#define VGA_DAC_TO_COLOR(x) (((x) << 2) | ((x) >> 6))
#define VGA_COLOR_TO_DAC(x) ((x) >> 2)
/* Sequencer reset register bits */
#define VGA_SEQ_RESET_AR (1 << 0)
@ -194,7 +197,7 @@ VOID VgaWriteMemory(DWORD Address, LPBYTE Buffer, DWORD Size);
BYTE VgaReadPort(WORD Port);
VOID VgaWritePort(WORD Port, BYTE Data);
VOID VgaClearMemory(VOID);
VOID VgaInitialize(HANDLE TextHandle);
BOOLEAN VgaInitialize(HANDLE TextHandle);
#endif // _VGA_H_

View file

@ -25,6 +25,7 @@ CSR_API(SrvGetConsoleNumberOfInputEvents);
/* conoutput.c */
CSR_API(SrvInvalidateBitMapRect);
CSR_API(SrvSetConsolePalette);
CSR_API(SrvReadConsoleOutput);
CSR_API(SrvWriteConsole);
CSR_API(SrvWriteConsoleOutput);

View file

@ -203,6 +203,16 @@ ConDrvInvalidateBitMapRect(IN PCONSOLE Console,
return STATUS_SUCCESS;
}
NTSTATUS NTAPI
ConDrvSetConsolePalette(IN PCONSOLE Console,
IN PGRAPHICS_SCREEN_BUFFER Buffer,
IN HPALETTE PaletteHandle,
IN UINT Usage)
{
DPRINT1("ConDrvSetConsolePalette is UNIMPLEMENTED but returns STATUS_SUCCESS\n");
return STATUS_SUCCESS;
}
NTSTATUS NTAPI
ConDrvGetConsoleCursorInfo(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,

View file

@ -50,6 +50,36 @@ CSR_API(SrvInvalidateBitMapRect)
return Status;
}
NTSTATUS NTAPI
ConDrvSetConsolePalette(IN PCONSOLE Console,
IN PGRAPHICS_SCREEN_BUFFER Buffer,
IN HPALETTE PaletteHandle,
IN UINT Usage);
CSR_API(SrvSetConsolePalette)
{
NTSTATUS Status;
PCONSOLE_SETPALETTE SetPaletteRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetPaletteRequest;
// PCONSOLE_SCREEN_BUFFER Buffer;
PGRAPHICS_SCREEN_BUFFER Buffer;
DPRINT("SrvSetConsolePalette\n");
// NOTE: Tests show that this function is used only for graphics screen buffers
// and otherwise it returns false + sets last error to invalid handle.
Status = ConSrvGetGraphicsBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetPaletteRequest->OutputHandle,
&Buffer, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Status = ConDrvSetConsolePalette(Buffer->Header.Console,
Buffer,
SetPaletteRequest->PaletteHandle,
SetPaletteRequest->Usage);
ConSrvReleaseScreenBuffer(Buffer, TRUE);
return Status;
}
NTSTATUS NTAPI
ConDrvGetConsoleCursorInfo(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,

View file

@ -220,7 +220,7 @@ CSR_API(SrvSetConsoleCursor)
PCONSOLE_SCREEN_BUFFER Buff;
// FIXME: Tests show that this function is used only for graphics screen buffers
// and otherwise it returns false + set last error to invalid handle.
// and otherwise it returns false + sets last error to invalid handle.
// NOTE: I find that behaviour is ridiculous but ok, let's accept that at the moment...
Status = ConSrvGetGraphicsBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetCursorRequest->OutputHandle,

View file

@ -75,7 +75,7 @@ PCSR_API_ROUTINE ConsoleServerApiDispatchTable[ConsolepMaxApiNumber - CONSRV_FIR
SrvSetConsoleCursor,
SrvShowConsoleCursor,
SrvConsoleMenuControl,
// SrvSetConsolePalette,
SrvSetConsolePalette,
SrvSetConsoleDisplayMode,
// SrvRegisterConsoleVDM,
SrvGetConsoleHardwareState,
@ -166,7 +166,7 @@ BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber - CONSRV_FIRST_API
FALSE, // SrvSetConsoleCursor,
FALSE, // SrvShowConsoleCursor,
FALSE, // SrvConsoleMenuControl,
// FALSE, // SrvSetConsolePalette,
FALSE, // SrvSetConsolePalette,
FALSE, // SrvSetConsoleDisplayMode,
// FALSE, // SrvRegisterConsoleVDM,
FALSE, // SrvGetConsoleHardwareState,
@ -257,7 +257,7 @@ PCHAR ConsoleServerApiNameTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER]
"SetConsoleCursor",
"ShowConsoleCursor",
"ConsoleMenuControl",
// "SetConsolePalette",
"SetConsolePalette",
"SetConsoleDisplayMode",
// "RegisterConsoleVDM",
"GetConsoleHardwareState",