Robert Reif wrote:
Robert Reif wrote:
Add stubs for NeedReboot and NeedRebootInit.
without FIXME bug
This time with three more functions implemented and some tests.
Some of the new code was borrowed from reactos. GetVersionFromFile* is badly broken in reactos so I don't really trust IsNTAdmin. I only tested this against an XP native dll so I don't know how win9x will do. Also only tested with English.
Please look over this carefully.
Index: configure.ac =================================================================== RCS file: /home/wine/wine/configure.ac,v retrieving revision 1.333 diff -u -r1.333 configure.ac --- configure.ac 10 Jan 2005 13:26:33 -0000 1.333 +++ configure.ac 11 Jan 2005 03:58:01 -0000 @@ -1511,6 +1511,7 @@ dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile +dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile Index: dlls/advpack/Makefile.in =================================================================== RCS file: /home/wine/wine/dlls/advpack/Makefile.in,v retrieving revision 1.1 diff -u -r1.1 Makefile.in --- dlls/advpack/Makefile.in 27 Sep 2004 20:39:40 -0000 1.1 +++ dlls/advpack/Makefile.in 11 Jan 2005 03:58:01 -0000 @@ -3,12 +3,14 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = advpack.dll -IMPORTS = setupapi user32 kernel32 ntdll +IMPORTS = setupapi user32 kernel32 ntdll version advapi32 EXTRALIBS = $(LIBUNICODE)
C_SRCS = \ advpack.c \ reg.c + +SUBDIRS = tests
@MAKE_DLL_RULES@
Index: dlls/advpack/advpack.c =================================================================== RCS file: /home/wine/wine/dlls/advpack/advpack.c,v retrieving revision 1.6 diff -u -r1.6 advpack.c --- dlls/advpack/advpack.c 15 Dec 2004 10:52:57 -0000 1.6 +++ dlls/advpack/advpack.c 11 Jan 2005 03:58:02 -0000 @@ -24,6 +24,8 @@ #include "winbase.h" #include "winuser.h" #include "winreg.h" +#include "winver.h" +#include "winnls.h" #include "setupapi.h" #include "advpub.h" #include "wine/debug.h" @@ -95,4 +97,139 @@ SetupCloseInfFile(hinf);
return ret; +} + +/*********************************************************************** + * NeedRebootInit (ADVPACK.@) + */ +DWORD WINAPI NeedRebootInit(VOID) +{ + FIXME("() stub!\n"); + + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + + return 0; +} + +/*********************************************************************** + * NeedReboot (ADVPACK.@) + */ +BOOL WINAPI NeedReboot(DWORD dwRebootCheck) +{ + FIXME("(0x%08lx) stub!\n", dwRebootCheck); + + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + + return FALSE; +} + +/*********************************************************************** + * GetVersionFromFileEx (ADVPACK.@) + */ +HRESULT WINAPI GetVersionFromFileEx( LPSTR lpszFilename, LPDWORD pdwMSVer, + LPDWORD pdwLSVer, BOOL bVersion ) +{ + DWORD hdl, retval; + LPVOID pVersionInfo; + BOOL boolret; + VS_FIXEDFILEINFO *pFixedVersionInfo; + UINT uiLength; + TRACE("(%s, %p, %p, %d)\n", lpszFilename, pdwMSVer, pdwLSVer, bVersion); + + if (bVersion) + { + retval = GetFileVersionInfoSizeA(lpszFilename, &hdl); + if (retval == 0 || hdl != 0) + return E_FAIL; + + pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval); + if (pVersionInfo == NULL) + return E_FAIL; + + GetFileVersionInfoA( lpszFilename, 0, retval, pVersionInfo); + + boolret = VerQueryValueA(pVersionInfo, "\", + (LPVOID) &pFixedVersionInfo, &uiLength); + + HeapFree(GetProcessHeap(), 0, pVersionInfo); + + if (boolret) + { + *pdwMSVer = pFixedVersionInfo->dwFileVersionMS; + *pdwLSVer = pFixedVersionInfo->dwFileVersionLS; + } + else + return E_FAIL; + } + else + { + *pdwMSVer = GetUserDefaultUILanguage(); + *pdwLSVer = GetACP(); + } + + return S_OK; +} + +/*********************************************************************** + * GetVersionFromFile (ADVPACK.@) + */ +HRESULT WINAPI GetVersionFromFile( LPSTR Filename, LPDWORD MajorVer, + LPDWORD MinorVer, BOOL Version ) +{ + TRACE("(%s, %p, %p, %d)\n", Filename, MajorVer, MinorVer, Version); + + return GetVersionFromFileEx(Filename, MajorVer, MinorVer, Version); +} + +/*********************************************************************** + * IsNTAdmin (ADVPACK.@) + */ +BOOL WINAPI IsNTAdmin( DWORD Reserved, PDWORD PReserved ) +{ + HANDLE Process, Token; + INT i; + BOOL Good = FALSE; + DWORD Buffer[4096]; + DWORD Size; + PTOKEN_GROUPS TokenGrp = (PTOKEN_GROUPS) Buffer; + SID_IDENTIFIER_AUTHORITY AuthSid = {SECURITY_NT_AUTHORITY}; + PSID psid = NULL; + + Process = GetCurrentProcess(); + + if ( OpenProcessToken(Process, TOKEN_QUERY, &Token) == FALSE) + { + CloseHandle(Process); + return FALSE; + } + + if ( GetTokenInformation( Token, TokenGroups, Buffer, 4096, &Size) == FALSE) + { + CloseHandle(Process); + CloseHandle(Token); + return FALSE; + } + + CloseHandle(Process); + CloseHandle(Token); + + if ( AllocateAndInitializeSid( &AuthSid, 2, SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, + &psid) == FALSE) + { + return FALSE; + } + + for ( i = 0; i < TokenGrp->GroupCount; i++ ) + { + if ( EqualSid( psid , TokenGrp->Groups[i].Sid) != FALSE ) + { + Good = TRUE; + break; + } + } + + FreeSid( psid); + + return Good; } Index: dlls/advpack/advpack.spec =================================================================== RCS file: /home/wine/wine/dlls/advpack/advpack.spec,v retrieving revision 1.4 diff -u -r1.4 advpack.spec --- dlls/advpack/advpack.spec 15 Dec 2004 10:52:57 -0000 1.4 +++ dlls/advpack/advpack.spec 11 Jan 2005 03:58:02 -0000 @@ -10,13 +10,13 @@ @ stub FileSaveMarkNotExist @ stub FileSaveRestore @ stub FileSaveRestoreOnINF -@ stub GetVersionFromFile -@ stub GetVersionFromFileEx -@ stub IsNTAdmin +@ stdcall GetVersionFromFile(str ptr ptr long) +@ stdcall GetVersionFromFileEx(str ptr ptr long) +@ stdcall IsNTAdmin(long ptr) @ stdcall LaunchINFSection(ptr ptr str long) @ stdcall LaunchINFSectionEx(ptr ptr str long) -@ stub NeedReboot -@ stub NeedRebootInit +@ stdcall NeedReboot(long) +@ stdcall NeedRebootInit() @ stub OpenINFEngine @ stub RebootCheckOnInstall @ stdcall RegInstall(ptr str ptr) Index: include/advpub.h =================================================================== RCS file: /home/wine/wine/include/advpub.h,v retrieving revision 1.1 diff -u -r1.1 advpub.h --- include/advpub.h 27 Sep 2004 20:39:40 -0000 1.1 +++ include/advpub.h 11 Jan 2005 03:58:14 -0000 @@ -39,6 +39,10 @@ typedef CSTRTABLE *LPCSTRTABLE;
HRESULT WINAPI RegInstall(HMODULE hm, LPCSTR pszSection, LPCSTRTABLE pstTable); +DWORD WINAPI NeedRebootInit(VOID); +BOOL WINAPI NeedReboot(DWORD dwRebootCheck); +HRESULT WINAPI GetVersionFromFile(LPSTR lpszFilename, LPDWORD pdwMSVer, LPDWORD pdwLSVer, BOOL bVersion); +BOOL WINAPI IsNTAdmin( DWORD dwReserved, DWORD *lpdwReserved );
#ifdef __cplusplus }