naive USER32.ExitWindows

svn path=/trunk/; revision=469
This commit is contained in:
Emanuele Aliberti 1999-05-15 13:35:57 +00:00
parent 19c00dc04f
commit 6ddcb50e38
3 changed files with 184 additions and 28 deletions

View file

@ -681,7 +681,8 @@ SetFileTime = SetFileTime@16
;SetHandleCount@4
;SetHandleInformation@12
;SetLastConsoleEventActive@0
;SetLastError@4
SetLastError = SetLastError@4
SetLastError@4
SetLocalTime@4
SetLocalTime = SetLocalTime@4
;SetLocaleInfoA@12

View file

@ -1,58 +1,83 @@
# $Id: makefile_rex,v 1.2 1999/05/15 13:35:57 ea Exp $
#
# ReactOS Operating System
#
# Makefile for user32.dll
#
include ../../rules.mak
TARGET=user32
ifneq ($(HOST),mingw32-windows)
ifneq ($(HOST),mingw32-linux)
DLLTARGET=user32.a
DLLTARGET=$(TARGET).a
else
DLLTARGET=user32.dll
DLLTARGET=$(TARGET).dll
endif
else
DLLTARGET=user32.dll
DLLTARGET=$(TARGET).dll
endif
all: $(DLLTARGET)
MISC_OBJECTS = misc/sprintf.o misc/dllmain.o
MISC_OBJECTS = misc/sprintf.o misc/exitwin.o misc/dllmain.o
RESOURCE_OBJECT = user32.coff
RESOURCE_OBJECT = $(TARGET).coff
OBJECTS = $(MISC_OBJECTS) $(RESOURCE_OBJECT)
ifeq ($(DOSCLI),yes)
CLEAN_FILES = misc\*.o \
user32.o user32.a junk.tmp base.tmp temp.exp user32.dll user32.sym
$(TARGET).o $(TARGET).a junk.tmp base.tmp temp.exp $(TARGET).dll $(TARGET).sym
else
CLEAN_FILES = misc/*.o \
user32.o user32.a junk.tmp base.tmp temp.exp user32.dll user32.sym
$(TARGET).o $(TARGET).a junk.tmp base.tmp temp.exp $(TARGET).dll $(TARGET).sym
endif
user32.coff: user32.rc ../../include/reactos/resource.h
windres user32.rc user32.coff
$(TARGET).coff: $(TARGET).rc ../../include/reactos/resource.h
$(RC) $(TARGET).rc $(TARGET).coff
user32.a: $(OBJECTS)
$(AR) csr user32.a $(OBJECTS)
$(TARGET).a: $(OBJECTS)
$(AR) csr $(TARGET).a $(OBJECTS)
user32.dll: $(DLLMAIN) $(OBJECTS) user32.def
$(LD) -r $(OBJECTS) -o user32.o
$(DLLTOOL) --dllname user32.dll --def user32.def \
--output-lib user32.a --add-stdcall-alias \
--kill-at
$(CC) -specs=user32_specs -mdll -o junk.tmp \
-Wl,--base-file,base.tmp user32.o ../ntdll/ntdll.a
$(TARGET).dll: $(DLLMAIN) $(OBJECTS) $(TARGET).def
$(LD) -r $(OBJECTS) -o $(TARGET).o
$(DLLTOOL) \
--dllname $(TARGET).dll \
--def $(TARGET).def \
--output-lib $(TARGET).a \
--add-stdcall-alias \
--kill-at
$(CC) $(TARGET).o \
../ntdll/ntdll.a \
../kernel32/kernel32.a \
-specs=$(TARGET)_specs \
-mdll \
-o junk.tmp \
-Wl,--base-file,base.tmp
- $(RM) junk.tmp
$(DLLTOOL) --dllname user32.dll --base-file base.tmp \
--output-exp temp.exp --def user32.def \
--add-stdcall-alias --kill-at
$(DLLTOOL) \
--dllname $(TARGET).dll \
--base-file base.tmp \
--output-exp temp.exp \
--def $(TARGET).def \
--add-stdcall-alias \
--kill-at
- $(RM) base.tmp
$(CC) -specs=user32_specs -mdll -o user32.dll user32.o ../ntdll/ntdll.a\
-Wl,--image-base,0x70000000 \
-Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-Wl,temp.exp
$(CC) $(TARGET).o \
../ntdll/ntdll.a\
../kernel32/kernel32.a \
-specs=$(TARGET)_specs \
-mdll \
-o $(TARGET).dll \
-Wl,--image-base,0x70000000 \
-Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-Wl,temp.exp
- $(RM) temp.exp
$(NM) --numeric-sort user32.dll > user32.sym
$(NM) --numeric-sort $(TARGET).dll > $(TARGET).sym
clean: $(CLEAN_FILES:%=%_clean)
@ -61,3 +86,4 @@ $(CLEAN_FILES:%=%_clean): %_clean:
.PHONY: clean $(CLEAN_FILES:%=%_clean)
# EOF

View file

@ -0,0 +1,129 @@
/* $Id: exitwin.c,v 1.1 1999/05/15 13:35:57 ea Exp $
*
* exitwin.c
*
* Copyright (c) 1999 Emanuele Aliberti
*
* --------------------------------------------------------------------
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this software; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
* --------------------------------------------------------------------
*
* ReactOS user32.dll ExitWindows functions.
*
* 19990515 EA Naive implementation.
*/
#include <windows.h>
#include <ddk/ntddk.h>
/***********************************************************************
* ExitWindowsEx
*
* ARGUMENTS
* uFlags shutdown operation
* EWX_FORCE Processes are killed.
*
* EWX_LOGOFF Caller owned processed are killed.
*
* EWX_POWEROFF Turns off the power.
*
* EWX_REBOOT Restart the system.
* SE_SHUTDOWN_NAME privilege reqired.
*
* EWX_SHUTDOWN Same as EWX_REBOOT, but rebooting.
* SE_SHUTDOWN_NAME privilege reqired.
*
* dwReserved reserved
*
* REVISIONS
* 1999-05-15 EA
*/
BOOL
__stdcall
ExitWindowsEx(
UINT uFlags,
DWORD dwReserved
)
{
NTSTATUS rv;
if (uFlags & (
EWX_FORCE |
EWX_LOGOFF |
EWX_POWEROFF |
EWX_REBOOT |
EWX_SHUTDOWN
)
) {
/* Unknown flag! */
SetLastError(ERROR_INVALID_FLAG_NUMBER);
return FALSE;
}
/* FIXME: call csrss.exe;
*
* Naive implementation: call the kernel directly.
* This code will be moved in csrss.exe when
* available.
*/
if (EWX_POWEROFF & uFlags)
{
rv = NtShutdownSystem(ShutdownPowerOff);
}
else if (EWX_REBOOT & uFlags)
{
rv = NtShutdownSystem(ShutdownReboot);
}
else if (EWX_SHUTDOWN & uFlags)
{
rv = NtShutdownSystem(ShutdownNoReboot);
}
else
{
/* How to implement others flags semantics? */
SetLastError(ERROR_INVALID_FLAG_NUMBER);
rv = (NTSTATUS) -1;
}
return NT_SUCCESS(rv)
? TRUE
: FALSE;
}
/***********************************************************************
* ExitWindows
*
* ARGUMENTS
* dwReserved, reserved
* uReserved reserved
*/
BOOL
__stdcall
ExitWindows(
DWORD dwReserved, // reserved
UINT uReserved // reserved
)
{
return ExitWindowsEx(
EWX_SHUTDOWN,
dwReserved
);
}
/* EOF */