ReactOS 0.4.15-dev-6056-gb29b268
install.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winuser.h"
#include "winreg.h"
#include "winsvc.h"
#include "setupapi.h"
#include "shlobj.h"
#include "wine/test.h"
Include dependency graph for install.c:

Go to the source code of this file.

Functions

static void create_inf_file (LPCSTR filename, const char *data)
 
static LRESULT CALLBACK cbt_hook_proc (int nCode, WPARAM wParam, LPARAM lParam)
 
static void run_cmdline (LPCSTR section, int mode, LPCSTR path)
 
static void ok_registry (BOOL expectsuccess)
 
static void test_cmdline (void)
 
static void test_registry (void)
 
static void test_install_from (void)
 
static void test_install_svc_from (void)
 
static void test_driver_install (void)
 
static void test_profile_items (void)
 
static void test_inffilelistA (void)
 
static void test_inffilelist (void)
 
static void check_dirid (int dirid, LPCSTR expected)
 
static void test_dirid (void)
 
 START_TEST (install)
 

Variables

static const char inffile [] = "test.inf"
 
static const WCHAR inffileW [] = {'t','e','s','t','.','i','n','f',0}
 
static char CURR_DIR [MAX_PATH]
 
static HHOOK hhook
 
static const charcmdline_inf
 
static const charcmdline_inf_reg
 
static const char dirid_inf []
 

Function Documentation

◆ cbt_hook_proc()

static LRESULT CALLBACK cbt_hook_proc ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 70 of file install.c.

71{
72 return nCode == HCBT_CREATEWND ? 1: CallNextHookEx(hhook, nCode, wParam, lParam);
73}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HHOOK hhook
Definition: install.c:69
#define HCBT_CREATEWND
Definition: winuser.h:58
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)

Referenced by START_TEST().

◆ check_dirid()

static void check_dirid ( int  dirid,
LPCSTR  expected 
)
static

Definition at line 713 of file install.c.

714{
715 char buffer[sizeof(dirid_inf)+11];
716 char path[MAX_PATH], actual[MAX_PATH];
717 LONG ret;
718 DWORD size, type;
719 HKEY key;
720
721 sprintf(buffer, dirid_inf, dirid);
722
724
725 sprintf(path, "%s\\%s", CURR_DIR, inffile);
726 run_cmdline("DefaultInstall", 128, path);
727
728 size = sizeof(actual);
729 actual[0] = '\0';
730 ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest", &key);
731 if (ret == ERROR_SUCCESS)
732 {
733 ret = RegQueryValueExA(key, "dirid", NULL, &type, (BYTE*)&actual, &size);
735 if (type != REG_SZ)
737 }
738
739 ok(ret == ERROR_SUCCESS, "Failed getting value for dirid %i, err=%d\n", dirid, ret);
740 ok(!strcmp(actual, expected), "Expected path for dirid %i was \"%s\", got \"%s\"\n", dirid, expected, actual);
741
744 ok(ret, "Expected source inf to exist, last error was %d\n", GetLastError());
745}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: atltest.h:57
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3254
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4024
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static void create_inf_file(void)
Definition: advpack.c:202
static char CURR_DIR[MAX_PATH]
Definition: install.c:32
BOOL expected
Definition: store.c:2063
static void ok_registry(BOOL expectsuccess)
Definition: install.c:96
static const char dirid_inf[]
Definition: install.c:706
static void run_cmdline(LPCSTR section, int mode, LPCSTR path)
Definition: install.c:86
static const char inffile[]
Definition: install.c:37
long LONG
Definition: pedump.c:60
Definition: copy.c:22
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define HKEY_CURRENT_USER
Definition: winreg.h:11
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_dirid().

◆ create_inf_file()

static void create_inf_file ( LPCSTR  filename,
const char data 
)
static

Definition at line 56 of file install.c.

57{
58 DWORD res;
59 BOOL ret;
64 assert(ret != 0);
66}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define assert(x)
Definition: debug.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
const char * filename
Definition: ioapi.h:137
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90

◆ ok_registry()

static void ok_registry ( BOOL  expectsuccess)
static

Definition at line 96 of file install.c.

97{
98 LONG ret;
99
100 /* Functional tests for success of install and clean up */
101 ret = RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest");
102 ok((expectsuccess && ret == ERROR_SUCCESS) ||
103 (!expectsuccess && ret == ERROR_FILE_NOT_FOUND),
104 "Expected registry key Software\\Wine\\setupapitest to %s, RegDeleteKey returned %d\n",
105 expectsuccess ? "exist" : "not exist",
106 ret);
107}
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1219

Referenced by check_dirid(), and test_cmdline().

◆ run_cmdline()

static void run_cmdline ( LPCSTR  section,
int  mode,
LPCSTR  path 
)
static

Definition at line 86 of file install.c.

87{
89 WCHAR cmdlinew[MAX_PATH * 2];
90
91 sprintf(cmdline, "%s %d %s", section, mode, path);
92 MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlinew, MAX_PATH*2);
93 InstallHinfSectionW(NULL, NULL, cmdlinew, 0);
94}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
void WINAPI InstallHinfSectionW(HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, INT show)
Definition: install.c:1465
GLenum mode
Definition: glext.h:6217
TCHAR * cmdline
Definition: stretchblt.cpp:32
Definition: parser.c:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

Referenced by check_dirid(), test_cmdline(), test_driver_install(), test_profile_items(), and test_registry().

◆ START_TEST()

START_TEST ( install  )

Definition at line 764 of file install.c.

765{
766 char temp_path[MAX_PATH], prev_path[MAX_PATH];
767 DWORD len;
768
769 GetCurrentDirectoryA(MAX_PATH, prev_path);
772
775 if(len && (CURR_DIR[len - 1] == '\\'))
776 CURR_DIR[len - 1] = 0;
777
778 /* Set CBT hook to disallow MessageBox creation in current thread */
780 assert(hhook != 0);
781
782 test_cmdline();
787 test_dirid();
788
790
791 /* We have to run this test after the CBT hook is disabled because
792 ProfileItems needs to create a window on Windows XP. */
794
797
798 SetCurrentDirectoryA(prev_path);
799}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2206
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
GLenum GLsizei len
Definition: glext.h:6722
static void test_registry(void)
Definition: install.c:145
static void test_install_svc_from(void)
Definition: install.c:216
static void test_inffilelistA(void)
Definition: install.c:493
static void test_cmdline(void)
Definition: install.c:110
static void test_install_from(void)
Definition: install.c:177
static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: install.c:70
static void test_profile_items(void)
Definition: install.c:432
static void test_dirid(void)
Definition: install.c:748
static void test_inffilelist(void)
Definition: install.c:546
static void test_driver_install(void)
Definition: install.c:360
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define WH_CBT
Definition: winuser.h:35
HHOOK WINAPI SetWindowsHookExA(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)

◆ test_cmdline()

static void test_cmdline ( void  )
static

Definition at line 110 of file install.c.

111{
112 static const char infwithspaces[] = "test file.inf";
113 char path[MAX_PATH];
114 BOOL ret;
115
117 sprintf(path, "%s\\%s", CURR_DIR, inffile);
118 run_cmdline("DefaultInstall", 128, path);
121 ok(ret, "Expected source inf to exist, last error was %d\n", GetLastError());
122
123 /* Test handling of spaces in path, unquoted and quoted */
124 create_inf_file(infwithspaces, cmdline_inf);
125
126 sprintf(path, "%s\\%s", CURR_DIR, infwithspaces);
127 run_cmdline("DefaultInstall", 128, path);
129
130 sprintf(path, "\"%s\\%s\"", CURR_DIR, infwithspaces);
131 run_cmdline("DefaultInstall", 128, path);
133
134 ret = DeleteFileA(infwithspaces);
135 ok(ret, "Expected source inf to exist, last error was %d\n", GetLastError());
136}
#define FALSE
Definition: types.h:117
static const char * cmdline_inf
Definition: install.c:79

Referenced by START_TEST().

◆ test_dirid()

static void test_dirid ( void  )
static

Definition at line 748 of file install.c.

749{
750 char expected[MAX_PATH];
751
753
756
759
760 strcat(expected, "\\unknown");
762}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
static void check_dirid(int dirid, LPCSTR expected)
Definition: install.c:713
#define DIRID_SYSTEM
Definition: setupapi.h:188
#define DIRID_NULL
Definition: setupapi.h:185
#define DIRID_WINDOWS
Definition: setupapi.h:187

Referenced by START_TEST().

◆ test_driver_install()

static void test_driver_install ( void  )
static

Definition at line 360 of file install.c.

361{
363 SC_HANDLE scm_handle, svc_handle;
364 BOOL ret;
365 char path[MAX_PATH], windir[MAX_PATH], driver[MAX_PATH];
366 DWORD attrs;
367 /* Minimal stuff needed */
368 static const char *inf =
369 "[Version]\n"
370 "Signature=\"$Chicago$\"\n"
371 "[DestinationDirs]\n"
372 "Winetest.DriverFiles=12\n"
373 "[DefaultInstall]\n"
374 "CopyFiles=Winetest.DriverFiles\n"
375 "[DefaultInstall.Services]\n"
376 "AddService=Winetest,,Winetest.Service\n"
377 "[Winetest.Service]\n"
378 "ServiceBinary=%12%\\winetest.sys\n"
379 "ServiceType=1\n"
380 "StartType=4\n"
381 "ErrorControl=1\n"
382 "[Winetest.DriverFiles]\n"
383 "winetest.sys";
384
385 /* Bail out if we don't have enough rights */
386 SetLastError(0xdeadbeef);
389 {
390 skip("Not enough rights to install the service\n");
391 return;
392 }
394
395 /* Place where we expect the driver to be installed */
397 lstrcpyA(driver, windir);
398 lstrcatA(driver, "\\system32\\drivers\\winetest.sys");
399
400 /* Create a dummy driver file */
401 handle = CreateFileA("winetest.sys", GENERIC_WRITE, 0, NULL,
404
406 sprintf(path, "%s\\%s", CURR_DIR, inffile);
407 run_cmdline("DefaultInstall", 128, path);
408
409 /* Driver should have been installed */
410 attrs = GetFileAttributesA(driver);
411 ok(attrs != INVALID_FILE_ATTRIBUTES, "Expected driver to exist\n");
412
414
415 /* Open the service to see if it's really there */
416 svc_handle = OpenServiceA(scm_handle, "Winetest", DELETE);
417 ok(svc_handle != NULL, "Service was not created\n");
418
419 SetLastError(0xdeadbeef);
420 ret = DeleteService(svc_handle);
421 ok(ret, "Service could not be deleted : %d\n", GetLastError());
422
423 CloseServiceHandle(svc_handle);
425
426 /* File cleanup */
428 DeleteFileA("winetest.sys");
430}
static SC_HANDLE scm_handle
Definition: ServiceArgs.c:20
#define skip(...)
Definition: atltest.h:64
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
struct @1646::@1647 driver
#define GENERIC_ALL
Definition: nt_native.h:92
#define DELETE
Definition: nt_native.h:57
BOOL WINAPI DeleteService(SC_HANDLE hService)
Definition: scm.c:921
SC_HANDLE WINAPI OpenServiceA(SC_HANDLE hSCManager, LPCSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2060
SC_HANDLE WINAPI OpenSCManagerA(LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:1972
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by START_TEST().

◆ test_inffilelist()

static void test_inffilelist ( void  )
static

Definition at line 546 of file install.c.

547{
548 static const char inffile2[] = "test2.inf";
549 static const WCHAR inffile2W[] = {'t','e','s','t','2','.','i','n','f',0};
550 static const char invalid_inf[] = "invalid.inf";
551 static const WCHAR invalid_infW[] = {'i','n','v','a','l','i','d','.','i','n','f',0};
552 static const char *inf =
553 "[Version]\n"
554 "Signature=\"$Chicago$\"";
555 static const char *inf2 =
556 "[Version]\n"
557 "Signature=\"$CHICAGO$\"";
558 static const char *infNT =
559 "[Version]\n"
560 "Signature=\"$WINDOWS NT$\"";
561
562 WCHAR *p, *ptr;
563 char dirA[MAX_PATH];
564 WCHAR dir[MAX_PATH] = { 0 };
565 WCHAR buffer[MAX_PATH] = { 0 };
567 BOOL ret;
568
569 /* NULL means %windir%\\inf
570 * get the value as reference
571 */
572 expected = 0;
573 SetLastError(0xdeadbeef);
575 ok(ret, "expected SetupGetInfFileListW to succeed! Error: %d\n", GetLastError());
576 ok(expected > 0, "expected required buffersize to be at least 1\n");
577
578 /* check if an empty string doesn't behaves like NULL */
579 outsize = 0;
580 SetLastError(0xdeadbeef);
582 ok(!ret, "expected SetupGetInfFileListW to fail!\n");
583
584 /* create a private directory, the temp directory may contain some
585 * inf files left over from old installations
586 */
587 if (!GetTempFileNameA(CURR_DIR, "inftest", 1, dirA))
588 {
589 win_skip("GetTempFileNameA failed with error %d\n", GetLastError());
590 return;
591 }
592 if (!CreateDirectoryA(dirA, NULL ))
593 {
594 win_skip("CreateDirectoryA(%s) failed with error %d\n", dirA, GetLastError());
595 return;
596 }
597 if (!SetCurrentDirectoryA(dirA))
598 {
599 win_skip("SetCurrentDirectoryA failed with error %d\n", GetLastError());
600 RemoveDirectoryA(dirA);
601 return;
602 }
603
604 MultiByteToWideChar(CP_ACP, 0, dirA, -1, dir, MAX_PATH);
605 /* check a not existing directory
606 */
607 ptr = dir + lstrlenW(dir);
608 MultiByteToWideChar(CP_ACP, 0, "\\not_existent", -1, ptr, MAX_PATH - lstrlenW(dir));
609 outsize = 0xffffffff;
610 SetLastError(0xdeadbeef);
612 ok(ret, "expected SetupGetInfFileListW to succeed!\n");
613 ok(outsize == 1, "expected required buffersize to be 1, got %d\n", outsize);
615 "expected error ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
616
618 create_inf_file(inffile2, inf);
619 create_inf_file(invalid_inf, "This content does not match the inf file format");
620
621 /* pass a filename instead of a directory
622 */
623 *ptr = '\\';
624 MultiByteToWideChar(CP_ACP, 0, invalid_inf, -1, ptr+1, MAX_PATH - lstrlenW(dir));
625 outsize = 0xffffffff;
626 SetLastError(0xdeadbeef);
628 ok(!ret, "expected SetupGetInfFileListW to fail!\n");
630 "expected error ERROR_DIRECTORY, got %d\n", GetLastError());
631
632 /* make the filename look like directory
633 */
634 dir[1 + lstrlenW(dir)] = 0;
635 dir[lstrlenW(dir)] = '\\';
636 SetLastError(0xdeadbeef);
638 ok(!ret, "expected SetupGetInfFileListW to fail!\n");
640 "expected error ERROR_DIRECTORY, got %d\n", GetLastError());
641
642 /* now check the buffer contents of a valid call
643 */
644 *ptr = 0;
645 expected = 3 + strlen(inffile) + strlen(inffile2);
647 ok(ret, "expected SetupGetInfFileListW to succeed!\n");
648 ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
650 for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
651 ok(!lstrcmpW(p,inffile2W) || !lstrcmpW(p,inffileW),
652 "unexpected filename %s\n",wine_dbgstr_w(p));
653
654 /* upper case value
655 */
656 create_inf_file(inffile2, inf2);
658 ok(ret, "expected SetupGetInfFileListW to succeed!\n");
659 ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
661 for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
662 ok(!lstrcmpW(p,inffile2W) || !lstrcmpW(p,inffileW),
663 "unexpected filename %s\n",wine_dbgstr_w(p));
664
665 /* signature Windows NT is also inf style win4
666 */
667 create_inf_file(inffile2, infNT);
668 expected = 3 + strlen(inffile) + strlen(inffile2);
670 ok(ret, "expected SetupGetInfFileListW to succeed!\n");
671 ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
673 for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
674 ok(!lstrcmpW(p,inffile2W) || !lstrcmpW(p,inffileW),
675 "unexpected filename %s\n",wine_dbgstr_w(p));
676
677 /* old style
678 */
679 expected = 2 + strlen(invalid_inf);
681 ok(ret, "expected SetupGetInfFileListW to succeed!\n");
682 ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
684 for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
685 ok(!lstrcmpW(p,invalid_infW), "unexpected filename %s\n",wine_dbgstr_w(p));
686
687 /* mixed style
688 */
689 expected = 4 + strlen(inffile) + strlen(inffile2) + strlen(invalid_inf);
691 MAX_PATH, &outsize);
692 ok(ret, "expected SetupGetInfFileListW to succeed!\n");
693 ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
695 for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
696 ok(!lstrcmpW(p,inffile2W) || !lstrcmpW(p,inffileW) || !lstrcmpW(p,invalid_infW),
697 "unexpected filename %s\n",wine_dbgstr_w(p));
698
700 DeleteFileA(inffile2);
701 DeleteFileA(invalid_inf);
703 RemoveDirectoryA(dirA);
704}
unsigned int dir
Definition: maze.c:112
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
BOOL WINAPI SetupGetInfFileListW(IN PCWSTR DirectoryPath OPTIONAL, IN DWORD InfStyle, IN OUT PWSTR ReturnBuffer OPTIONAL, IN DWORD ReturnBufferSize OPTIONAL, OUT PDWORD RequiredSize OPTIONAL)
Definition: parser.c:2139
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
GLfloat GLfloat p
Definition: glext.h:8902
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
#define INF_STYLE_WIN4
Definition: infsupp.h:41
unsigned char size_t * outsize
Definition: jpeglib.h:981
#define wine_dbgstr_w
Definition: kernel32.h:34
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR inffileW[]
Definition: install.c:38
#define win_skip
Definition: test.h:160
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_DIRECTORY
Definition: winerror.h:295

Referenced by START_TEST().

◆ test_inffilelistA()

static void test_inffilelistA ( void  )
static

Definition at line 493 of file install.c.

494{
495 static const char inffile2[] = "test2.inf";
496 static const char *inf =
497 "[Version]\n"
498 "Signature=\"$Chicago$\"";
499
500 char buffer[MAX_PATH] = { 0 };
501 char dir[MAX_PATH], *p;
503 BOOL ret;
504
505 /* create a private directory, the temp directory may contain some
506 * inf files left over from old installations
507 */
508 if (!GetTempFileNameA(CURR_DIR, "inftest", 1, dir))
509 {
510 win_skip("GetTempFileNameA failed with error %d\n", GetLastError());
511 return;
512 }
513 if (!CreateDirectoryA(dir, NULL ))
514 {
515 win_skip("CreateDirectoryA(%s) failed with error %d\n", dir, GetLastError());
516 return;
517 }
519 {
520 win_skip("SetCurrentDirectoryA failed with error %d\n", GetLastError());
522 return;
523 }
524
526 create_inf_file(inffile2, inf);
527
528 /* mixed style
529 */
530 expected = 3 + strlen(inffile) + strlen(inffile2);
532 MAX_PATH, &outsize);
533 ok(ret, "expected SetupGetInfFileListA to succeed!\n");
534 ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
536 for(p = buffer; lstrlenA(p) && (outsize > (p - buffer)); p+=lstrlenA(p) + 1)
537 ok(!lstrcmpA(p,inffile2) || !lstrcmpA(p,inffile),
538 "unexpected filename %s\n",p);
539
541 DeleteFileA(inffile2);
544}
BOOL WINAPI SetupGetInfFileListA(IN PCSTR DirectoryPath OPTIONAL, IN DWORD InfStyle, IN OUT PSTR ReturnBuffer OPTIONAL, IN DWORD ReturnBufferSize OPTIONAL, OUT PDWORD RequiredSize OPTIONAL)
Definition: parser.c:2272
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145

Referenced by START_TEST().

◆ test_install_from()

static void test_install_from ( void  )
static

Definition at line 177 of file install.c.

178{
179 char path[MAX_PATH];
180 HINF infhandle;
181 HKEY key;
182 LONG res;
183 BOOL ret;
184
185 /* First create a registry structure we would like to be deleted */
186 ok(!RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest\\setupapitest", &key),
187 "Expected RegCreateKeyA to succeed\n");
188
189 /* Doublecheck if the registry key is present */
190 ok(!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest\\setupapitest", &key),
191 "Expected registry key to exist\n");
192
194 sprintf(path, "%s\\%s", CURR_DIR, inffile);
196 SetLastError(0xdeadbeef);
197 ret = SetupInstallFromInfSectionA(NULL, infhandle, "DefaultInstall", SPINST_REGISTRY, key,
198 "A:\\", 0, NULL, NULL, NULL, NULL);
199 ok(ret, "Unexpected failure\n");
200 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
201
202 /* Check if the registry key is recursively deleted */
203 res = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest", &key);
204 ok(res == ERROR_FILE_NOT_FOUND, "Didn't expect the registry key to exist\n");
205 /* Just in case */
206 if (res == ERROR_SUCCESS)
207 {
208 RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest\\setupapitest");
209 RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest");
210 }
211
212 SetupCloseInfFile(infhandle);
214}
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1174
BOOL WINAPI SetupInstallFromInfSectionA(HWND owner, HINF hinf, PCSTR section, UINT flags, HKEY key_root, PCSTR src_root, UINT copy_flags, PSP_FILE_CALLBACK_A callback, PVOID context, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data)
Definition: install.c:1256
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
static const char * cmdline_inf_reg
Definition: install.c:138
#define SPINST_REGISTRY
Definition: setupapi.h:590
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43

Referenced by START_TEST().

◆ test_install_svc_from()

static void test_install_svc_from ( void  )
static

Definition at line 216 of file install.c.

217{
218 char inf[2048];
219 char path[MAX_PATH];
220 HINF infhandle;
221 BOOL ret;
222 SC_HANDLE scm_handle, svc_handle;
223
224 /* Basic inf file to satisfy SetupOpenInfFileA */
225 strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
227 sprintf(path, "%s\\%s", CURR_DIR, inffile);
229
230 /* Nothing but the Version section */
231 SetLastError(0xdeadbeef);
232 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
233 ok(!ret, "Expected failure\n");
235 "Expected ERROR_SECTION_NOT_FOUND, got %08x\n", GetLastError());
236 SetupCloseInfFile(infhandle);
238
239 /* Add the section */
240 strcat(inf, "[Winetest.Services]\n");
243 SetLastError(0xdeadbeef);
244 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
245 ok(!ret, "Expected failure\n");
247 "Expected ERROR_SECTION_NOT_FOUND, got %08x\n", GetLastError());
248 SetupCloseInfFile(infhandle);
250
251 /* Add a reference */
252 strcat(inf, "AddService=Winetest,,Winetest.Service\n");
255 SetLastError(0xdeadbeef);
256 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
257 ok(!ret, "Expected failure\n");
259 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
260 SetupCloseInfFile(infhandle);
262
263 /* Add the section */
264 strcat(inf, "[Winetest.Service]\n");
267 SetLastError(0xdeadbeef);
268 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
269 ok(!ret, "Expected failure\n");
271 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
272 SetupCloseInfFile(infhandle);
274
275 /* Just the ServiceBinary */
276 strcat(inf, "ServiceBinary=%12%\\winetest.sys\n");
279 SetLastError(0xdeadbeef);
280 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
281 ok(!ret, "Expected failure\n");
283 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
284 SetupCloseInfFile(infhandle);
286
287 /* Add the ServiceType */
288 strcat(inf, "ServiceType=1\n");
291 SetLastError(0xdeadbeef);
292 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
293 ok(!ret, "Expected failure\n");
295 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
296 SetupCloseInfFile(infhandle);
298
299 /* Add the StartType */
300 strcat(inf, "StartType=4\n");
303 SetLastError(0xdeadbeef);
304 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
305 ok(!ret, "Expected failure\n");
307 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
308 SetupCloseInfFile(infhandle);
310
311 /* This should be it, the minimal entries to install a service */
312 strcat(inf, "ErrorControl=1");
315 SetLastError(0xdeadbeef);
316 ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0);
318 {
319 skip("Not enough rights to install the service\n");
320 SetupCloseInfFile(infhandle);
322 return;
323 }
324 ok(ret, "Expected success\n");
326 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
327 SetupCloseInfFile(infhandle);
329
331
332 /* Open the service to see if it's really there */
333 svc_handle = OpenServiceA(scm_handle, "Winetest", DELETE);
334 ok(svc_handle != NULL, "Service was not created\n");
335
336 SetLastError(0xdeadbeef);
337 ret = DeleteService(svc_handle);
338 ok(ret, "Service could not be deleted : %d\n", GetLastError());
339
340 CloseServiceHandle(svc_handle);
342
343 strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
344 strcat(inf, "[XSP.InstallPerVer]\n");
345 strcat(inf, "AddReg=AspEventlogMsg.Reg,Perf.Reg,AspVersions.Reg,FreeADO.Reg,IndexServer.Reg\n");
347 sprintf(path, "%s\\%s", CURR_DIR, inffile);
349
350 SetLastError(0xdeadbeef);
351 ret = SetupInstallServicesFromInfSectionA(infhandle, "XSP.InstallPerVer", 0);
352 ok(ret, "Expected success\n");
353 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
354 SetupCloseInfFile(infhandle);
356
357 /* TODO: Test the Flags */
358}
BOOL WINAPI SetupInstallServicesFromInfSectionA(HINF Inf, PCSTR SectionName, DWORD Flags)
Definition: install.c:1621
#define ERROR_BAD_SERVICE_INSTALLSECT
Definition: setupapi.h:319
#define ERROR_SECTION_NOT_FOUND
Definition: setupapi.h:293

Referenced by START_TEST().

◆ test_profile_items()

static void test_profile_items ( void  )
static

Definition at line 432 of file install.c.

433{
434 char path[MAX_PATH], commonprogs[MAX_PATH];
435
436 static const char *inf =
437 "[Version]\n"
438 "Signature=\"$Chicago$\"\n"
439 "[DefaultInstall]\n"
440 "ProfileItems=TestItem,TestItem2,TestGroup\n"
441 "[TestItem]\n"
442 "Name=TestItem\n"
443 "CmdLine=11,,notepad.exe\n"
444 "[TestItem2]\n"
445 "Name=TestItem2\n"
446 "CmdLine=11,,notepad.exe\n"
447 "SubDir=TestDir\n"
448 "[TestGroup]\n"
449 "Name=TestGroup,4\n"
450 ;
451
453 {
454 skip("No common program files directory exists\n");
455 goto cleanup;
456 }
457
458 snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs);
460 {
461 skip("need admin rights\n");
462 return;
463 }
465
467 sprintf(path, "%s\\%s", CURR_DIR, inffile);
468 run_cmdline("DefaultInstall", 128, path);
469
470 snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs);
471 snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs);
472 ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "directory not created\n");
473 snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs);
474 ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "link not created\n");
475 snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs);
476 ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "group not created\n");
477
478 snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs);
480 snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs);
482 snprintf(path, MAX_PATH, "%s\\TestItem2.lnk", commonprogs);
484 snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs);
486 snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs);
488
489cleanup:
491}
static void cleanup(void)
Definition: main.c:1335
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2805
#define S_OK
Definition: intsafe.h:52
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2001
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2047
#define snprintf
Definition: wintirpc.h:48

Referenced by START_TEST().

◆ test_registry()

static void test_registry ( void  )
static

Definition at line 145 of file install.c.

146{
147 HKEY key;
148 LONG res;
149 char path[MAX_PATH];
150 BOOL ret;
151
152 /* First create a registry structure we would like to be deleted */
153 ok(!RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest\\setupapitest", &key),
154 "Expected RegCreateKeyA to succeed\n");
155
156 /* Doublecheck if the registry key is present */
157 ok(!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest\\setupapitest", &key),
158 "Expected registry key to exist\n");
159
161 sprintf(path, "%s\\%s", CURR_DIR, inffile);
162 run_cmdline("DefaultInstall", 128, path);
163
164 /* Check if the registry key is recursively deleted */
165 res = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest", &key);
166 ok(res == ERROR_FILE_NOT_FOUND, "Didn't expect the registry key to exist\n");
167 /* Just in case */
168 if (res == ERROR_SUCCESS)
169 {
170 RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest\\setupapitest");
171 RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Wine\\setupapitest");
172 }
174 ok(ret, "Expected source inf to exist, last error was %d\n", GetLastError());
175}

Referenced by START_TEST().

Variable Documentation

◆ cmdline_inf

const char* cmdline_inf
static
Initial value:
= "[Version]\n"
"Signature=\"$Chicago$\"\n"
"[DefaultInstall]\n"
"AddReg=Add.Settings\n"
"[Add.Settings]\n"
"HKCU,Software\\Wine\\setupapitest,,\n"

Definition at line 79 of file install.c.

Referenced by test_cmdline().

◆ cmdline_inf_reg

const char* cmdline_inf_reg
static
Initial value:
= "[Version]\n"
"Signature=\"$Chicago$\"\n"
"[DefaultInstall]\n"
"DelReg=Del.Settings\n"
"[Del.Settings]\n"
"HKCU,Software\\Wine\\setupapitest\n"

Definition at line 138 of file install.c.

Referenced by test_install_from(), and test_registry().

◆ CURR_DIR

char CURR_DIR[MAX_PATH]
static

Definition at line 39 of file install.c.

◆ dirid_inf

const char dirid_inf[]
static
Initial value:
= "[Version]\n"
"Signature=\"$Chicago$\"\n"
"[DefaultInstall]\n"
"AddReg=Add.Settings\n"
"[Add.Settings]\n"
"HKCU,Software\\Wine\\setupapitest,dirid,,%%%i%%\n"

Definition at line 706 of file install.c.

Referenced by check_dirid().

◆ hhook

HHOOK hhook
static

Definition at line 69 of file install.c.

Referenced by cbt_hook_proc(), and START_TEST().

◆ inffile

◆ inffileW

const WCHAR inffileW[] = {'t','e','s','t','.','i','n','f',0}
static

Definition at line 38 of file install.c.

Referenced by test_inffilelist().