module winbase;

export extern ( Windows )
{

const uint INFINITE = 0xffffffff;
const uint STANDARD_RIGHTS_REQUIRED = 0x000F0000;
const uint SYNCHRONIZE = 0x00100000L;

const uint EVENT_MODIFY_STATE = 0x0002;
const uint EVENT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3;

struct SECURITY_ATTRIBUTES
{
	uint nLength;
	void * lpSecurityDescriptor;
	int bInheritHandle;
}

alias SECURITY_ATTRIBUTES * PSECURITY_ATTRIBUTES;
alias SECURITY_ATTRIBUTES * LPSECURITY_ATTRIBUTES;

uint
GetLastError ();


void *
CreateEventA
(
	LPSECURITY_ATTRIBUTES lpEventAttributes,
	int bManualReset,
	int bInitialState,
	char * lpName
);

void *
CreateEventW
(
	LPSECURITY_ATTRIBUTES lpEventAttributes,
	int bManualReset,
	int bInitialState,
	char * lpName
);

version ( UNICODE )
{
	alias CreateEventW CreateEvent;
}
else
{
	alias CreateEventA CreateEvent;
}


void *
OpenEventA
(
	uint dwDesiredAccess,
	int bInheritHandle,
	char * lpName
);

void *
OpenEventW
(
	uint dwDesiredAccess,
	int bInheritHandle,
	char * lpName
);

version ( UNICODE )
{
	alias OpenEventW OpenEvent;
}
else
{
	alias OpenEventA OpenEvent;
}

int
SetEvent
(
	void * hEvent
);

int
ResetEvent
(
	void * hEvent
);

int
PulseEvent
(
	void * hEvent
);

uint
WaitForSingleObject
(
	void * hHandle,
	uint dwMilliseconds
);

uint
WaitForMultipleObjects
(
	uint nCount,
	void * * lpHandles,
	int bWaitAll,
	uint dwMilliseconds
);

int
CloseHandle
(
	void * hObject
);


void
OutputDebugStringA
(
	char * lpOutputString
);

void
OutputDebugStringW
(
	char * lpOutputString
);

version ( UNICODE )
{
	alias OutputDebugStringW OutputDebugString;
}
else
{
	alias OutputDebugStringA OutputDebugString;
}


void *
GetCurrentProcess ();

uint
GetCurrentProcessId ();


uint
GetModuleFileNameA
(
	void * hModule,
	out char * lpFilename,
	uint nSize
);

uint
GetModuleFileNameW
(
	void * hModule,
	out char * lpFilename,
	uint nSize
);

version ( UNICODE )
{
	alias GetModuleFileNameW GetModuleFileName;
}
else
{
	alias GetModuleFileNameA GetModuleFileName;
}

} // export extern ( Windows )
