Skip to content

Commit ef260b9

Browse files
committed
Finishing setup implementation
1 parent 45eb210 commit ef260b9

File tree

8 files changed

+211
-798
lines changed

8 files changed

+211
-798
lines changed

DriverInstaller-x64/DriverInstaller-x64.vdproj

Lines changed: 0 additions & 712 deletions
This file was deleted.

DriverInstaller/DriverInstaller.vdproj

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"VSVersion" = "3:800"
44
"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}"
55
"IsWebType" = "8:FALSE"
6-
"ProjectName" = "8:DriverInstaller-x86"
6+
"ProjectName" = "8:DriverInstaller"
77
"LanguageId" = "3:1033"
88
"CodePage" = "3:1252"
99
"UILanguageId" = "3:1033"
@@ -13,6 +13,12 @@
1313
"SccProvider" = "8:"
1414
"Hierarchy"
1515
{
16+
"Entry"
17+
{
18+
"MsmKey" = "8:_C378259A8D8C4FB880EAEC27ECC1720F"
19+
"OwnerKey" = "8:_UNDEFINED"
20+
"MsmSig" = "8:_UNDEFINED"
21+
}
1622
"Entry"
1723
{
1824
"MsmKey" = "8:_CACB481DB8B74D96B26F50DCA0C3F56A"
@@ -27,7 +33,7 @@
2733
"DisplayName" = "8:Debug"
2834
"IsDebugOnly" = "11:TRUE"
2935
"IsReleaseOnly" = "11:FALSE"
30-
"OutputFilename" = "8:Debug\\DriverInstaller.msi"
36+
"OutputFilename" = "8:..\\Release\\VibrationDriverInstaller.msi"
3137
"PackageFilesAs" = "3:2"
3238
"PackageFileSize" = "3:-2147483648"
3339
"CabType" = "3:1"
@@ -37,13 +43,21 @@
3743
"PrivateKeyFile" = "8:"
3844
"TimeStampServer" = "8:"
3945
"InstallerBootstrapper" = "3:2"
46+
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
47+
{
48+
"Enabled" = "11:TRUE"
49+
"PromptEnabled" = "11:TRUE"
50+
"PrerequisitesLocation" = "2:1"
51+
"Url" = "8:"
52+
"ComponentsUrl" = "8:"
53+
}
4054
}
4155
"Release"
4256
{
4357
"DisplayName" = "8:Release"
4458
"IsDebugOnly" = "11:FALSE"
4559
"IsReleaseOnly" = "11:TRUE"
46-
"OutputFilename" = "8:..\\Release\\VibrationDriverInstaller-x86.msi"
60+
"OutputFilename" = "8:..\\Release\\VibrationDriverInstaller.msi"
4761
"PackageFilesAs" = "3:2"
4862
"PackageFileSize" = "3:-2147483648"
4963
"CabType" = "3:1"
@@ -70,6 +84,20 @@
7084
{
7185
"CustomAction"
7286
{
87+
"{4AA51A2D-7D85-4A59-BA75-B0809FC8B380}:_A58FBA840C67404E868C9D92987CA01A"
88+
{
89+
"Name" = "8:GenericFFBDriver32.dll"
90+
"Condition" = "8:"
91+
"Object" = "8:_CACB481DB8B74D96B26F50DCA0C3F56A"
92+
"FileType" = "3:1"
93+
"InstallAction" = "3:1"
94+
"Arguments" = "8:"
95+
"EntryPoint" = "8:RegisterVibrationDriver"
96+
"Sequence" = "3:1"
97+
"Identifier" = "8:_E9FCB57E_3CD7_4256_8EE5_1BFB7014D07D"
98+
"InstallerClass" = "11:FALSE"
99+
"CustomActionData" = "8:"
100+
}
73101
}
74102
"DefaultFeature"
75103
{
@@ -85,12 +113,32 @@
85113
}
86114
"File"
87115
{
116+
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C378259A8D8C4FB880EAEC27ECC1720F"
117+
{
118+
"SourcePath" = "8:..\\Release\\GenericFFBDriver64.dll"
119+
"TargetName" = "8:GenericFFBDriver64.dll"
120+
"Tag" = "8:"
121+
"Folder" = "8:_08365EDD8FF742F7A8EA90AD36CEE015"
122+
"Condition" = "8:"
123+
"Transitive" = "11:FALSE"
124+
"Vital" = "11:TRUE"
125+
"ReadOnly" = "11:FALSE"
126+
"Hidden" = "11:FALSE"
127+
"System" = "11:FALSE"
128+
"Permanent" = "11:FALSE"
129+
"SharedLegacy" = "11:FALSE"
130+
"PackageAs" = "3:1"
131+
"Register" = "3:1"
132+
"Exclude" = "11:FALSE"
133+
"IsDependency" = "11:FALSE"
134+
"IsolateTo" = "8:"
135+
}
88136
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CACB481DB8B74D96B26F50DCA0C3F56A"
89137
{
90138
"SourcePath" = "8:..\\Release\\GenericFFBDriver32.dll"
91139
"TargetName" = "8:GenericFFBDriver32.dll"
92140
"Tag" = "8:"
93-
"Folder" = "8:_70D2A39DB17244D1A08BF53BE196346B"
141+
"Folder" = "8:_08365EDD8FF742F7A8EA90AD36CEE015"
94142
"Condition" = "8:"
95143
"Transitive" = "11:FALSE"
96144
"Vital" = "11:TRUE"
@@ -145,16 +193,31 @@
145193
{
146194
}
147195
}
196+
"{1525181F-901A-416C-8A58-119130FE478E}:_EB20EB274A8046AEA4621B3A08C74E43"
197+
{
198+
"Name" = "8:#1924"
199+
"AlwaysCreate" = "11:FALSE"
200+
"Condition" = "8:"
201+
"Transitive" = "11:FALSE"
202+
"Property" = "8:WindowsFolder"
203+
"Folders"
204+
{
205+
"{9EF0B969-E518-4E46-987F-47570745A589}:_08365EDD8FF742F7A8EA90AD36CEE015"
206+
{
207+
"Name" = "8:GenericFFBDriver"
208+
"AlwaysCreate" = "11:FALSE"
209+
"Condition" = "8:"
210+
"Transitive" = "11:FALSE"
211+
"Property" = "8:_C4024A52445545BFAFDC66ED44DCA719"
212+
"Folders"
213+
{
214+
}
215+
}
216+
}
217+
}
148218
}
149219
"LaunchCondition"
150220
{
151-
"{836E08B8-0285-4809-BA42-01DB6754A45D}:_CE465BB9F91247E294E9C0235D4ECCAC"
152-
{
153-
"Name" = "8:Machine_is_x64"
154-
"Condition" = "8:!VersionNT64"
155-
"Message" = "8:Please install the x64 driver"
156-
"InstallUrl" = "8:"
157-
}
158221
}
159222
"Locator"
160223
{
@@ -169,15 +232,15 @@
169232
"Name" = "8:Microsoft Visual Studio"
170233
"ProductName" = "8:Generic USB Gamepad Vibration Driver"
171234
"ProductCode" = "8:{50CD8B4D-CD82-49D1-9E0A-2B7887448068}"
172-
"PackageCode" = "8:{9637050A-F0CF-4529-95D3-3BD9C8410FAB}"
235+
"PackageCode" = "8:{C6059427-7868-44F2-86B6-E029402B5181}"
173236
"UpgradeCode" = "8:{A08375A2-DC94-4A88-8431-ED8D9717FA62}"
174237
"AspNetVersion" = "8:4.0.30319.0"
175238
"RestartWWWService" = "11:FALSE"
176239
"RemovePreviousVersions" = "11:FALSE"
177240
"DetectNewerInstalledVersion" = "11:TRUE"
178241
"InstallAllUsers" = "11:TRUE"
179242
"ProductVersion" = "8:1.0.0"
180-
"Manufacturer" = "8:Alessandro Menezes"
243+
"Manufacturer" = "8:Generic USB Gamepad Vibration Driver"
181244
"ARPHELPTELEPHONE" = "8:"
182245
"ARPHELPLINK" = "8:"
183246
"Title" = "8:Generic USB Gamepad Vibration Driver"
@@ -494,28 +557,6 @@
494557
}
495558
}
496559
}
497-
"{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_F2DB315D6C9C45D2BEFEDAE1DE489358"
498-
{
499-
"Sequence" = "3:200"
500-
"DisplayName" = "8:Installation Folder"
501-
"UseDynamicProperties" = "11:TRUE"
502-
"IsDependency" = "11:FALSE"
503-
"SourcePath" = "8:<VsdDialogDir>\\VsdAdminFolderDlg.wid"
504-
"Properties"
505-
{
506-
"BannerBitmap"
507-
{
508-
"Name" = "8:BannerBitmap"
509-
"DisplayName" = "8:#1001"
510-
"Description" = "8:#1101"
511-
"Type" = "3:8"
512-
"ContextData" = "8:Bitmap"
513-
"Attributes" = "3:4"
514-
"Setting" = "3:1"
515-
"UsePlugInResources" = "11:TRUE"
516-
}
517-
}
518-
}
519560
}
520561
}
521562
"{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_781D1A01A61242E48BB1652DE8A42A73"
@@ -575,41 +616,6 @@
575616
"Attributes" = "3:1"
576617
"Dialogs"
577618
{
578-
"{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_D2E3044385814E558FB3996F30200A15"
579-
{
580-
"Sequence" = "3:200"
581-
"DisplayName" = "8:Installation Folder"
582-
"UseDynamicProperties" = "11:TRUE"
583-
"IsDependency" = "11:FALSE"
584-
"SourcePath" = "8:<VsdDialogDir>\\VsdFolderDlg.wid"
585-
"Properties"
586-
{
587-
"BannerBitmap"
588-
{
589-
"Name" = "8:BannerBitmap"
590-
"DisplayName" = "8:#1001"
591-
"Description" = "8:#1101"
592-
"Type" = "3:8"
593-
"ContextData" = "8:Bitmap"
594-
"Attributes" = "3:4"
595-
"Setting" = "3:1"
596-
"UsePlugInResources" = "11:TRUE"
597-
}
598-
"InstallAllUsersVisible"
599-
{
600-
"Name" = "8:InstallAllUsersVisible"
601-
"DisplayName" = "8:#1059"
602-
"Description" = "8:#1159"
603-
"Type" = "3:5"
604-
"ContextData" = "8:1;True=1;False=0"
605-
"Attributes" = "3:0"
606-
"Setting" = "3:0"
607-
"Value" = "3:1"
608-
"DefaultValue" = "3:1"
609-
"UsePlugInResources" = "11:TRUE"
610-
}
611-
}
612-
}
613619
"{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_DD51DDF859CE471FA216BD8D94DC9BF2"
614620
{
615621
"Sequence" = "3:300"

GenericFFBDriver/GenericFFBDriver.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<WarningLevel>Level3</WarningLevel>
9595
<Optimization>Disabled</Optimization>
9696
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;GENERICFFBDRIVER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
97+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
9798
</ClCompile>
9899
<Link>
99100
<SubSystem>Windows</SubSystem>
@@ -127,6 +128,7 @@
127128
<FunctionLevelLinking>true</FunctionLevelLinking>
128129
<IntrinsicFunctions>true</IntrinsicFunctions>
129130
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GENERICFFBDRIVER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
131+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
130132
</ClCompile>
131133
<Link>
132134
<SubSystem>Windows</SubSystem>
@@ -189,6 +191,7 @@
189191
<ClCompile Include="FFBDriver.cpp" />
190192
<ClCompile Include="GenericFFBDriver.cpp" />
191193
<ClCompile Include="stdafx.cpp" />
194+
<ClCompile Include="VibrationDriverRegistration.cpp" />
192195
<ClCompile Include="vibration\VibrationController.cpp" />
193196
</ItemGroup>
194197
<ItemGroup>

GenericFFBDriver/GenericFFBDriver.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
<ClCompile Include="vibration\VibrationController.cpp">
6363
<Filter>Source Files</Filter>
6464
</ClCompile>
65+
<ClCompile Include="VibrationDriverRegistration.cpp">
66+
<Filter>Source Files</Filter>
67+
</ClCompile>
6568
</ItemGroup>
6669
<ItemGroup>
6770
<None Include="genericFFBDriver.def">
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#include "stdafx.h"
2+
#include <fstream>
3+
#include <filesystem>
4+
5+
#define DRIVER_x86 "GenericFFBDriver32.dll"
6+
#define DRIVER_x64 "GenericFFBDriver64.dll"
7+
8+
#ifdef _WIN64
9+
#define IS_WIN64 TRUE
10+
#else
11+
#define IS_WIN64 IsWow64()
12+
#endif
13+
14+
typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
15+
LPFN_ISWOW64PROCESS fnIsWow64Process;
16+
17+
typedef UINT(WINAPI *LPFN_GETSYSTEMWOW64DIRECTORY) (LPSTR, UINT);
18+
LPFN_GETSYSTEMWOW64DIRECTORY fnGetSystemWow64Directory;
19+
20+
BOOL IsWow64()
21+
{
22+
BOOL bIsWow64 = FALSE;
23+
24+
//IsWow64Process is not available on all supported versions of Windows.
25+
//Use GetModuleHandle to get a handle to the DLL that contains the function
26+
//and GetProcAddress to get a pointer to the function if available.
27+
28+
fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
29+
GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
30+
31+
if (NULL != fnIsWow64Process)
32+
{
33+
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
34+
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
35+
36+
_ASSERT(hr == S_OK);
37+
}
38+
}
39+
return bIsWow64;
40+
}
41+
42+
43+
int RunCommand(LPSTR cmd) {
44+
STARTUPINFOA si;
45+
PROCESS_INFORMATION pi;
46+
47+
ZeroMemory(&si, sizeof(si));
48+
si.cb = sizeof(si);
49+
ZeroMemory(&pi, sizeof(pi));
50+
51+
// Start the child process.
52+
if (!CreateProcessA(NULL, // No module name (use command line)
53+
cmd, // Command line
54+
NULL, // Process handle not inheritable
55+
NULL, // Thread handle not inheritable
56+
FALSE, // Set handle inheritance to FALSE
57+
0, // No creation flags
58+
NULL, // Use parent's environment block
59+
NULL, // Use parent's starting directory
60+
&si, // Pointer to STARTUPINFO structure
61+
&pi) // Pointer to PROCESS_INFORMATION structure
62+
)
63+
{
64+
printf("CreateProcess failed (%d).\n", GetLastError());
65+
return FALSE;
66+
}
67+
68+
// Wait until child process exits.
69+
WaitForSingleObject(pi.hProcess, INFINITE);
70+
71+
// Close process and thread handles.
72+
CloseHandle(pi.hProcess);
73+
CloseHandle(pi.hThread);
74+
75+
return TRUE;
76+
}
77+
78+
STDAPI RegisterVibrationDriver(void) {
79+
BOOL isWin64 = IS_WIN64;
80+
char systemPath[MAX_PATH];
81+
char cmdLine[MAX_PATH];
82+
char modulePath[MAX_PATH];
83+
84+
// Finding dll directory
85+
strcpy_s(modulePath, "");
86+
87+
HMODULE hModule = GetModuleHandleA(DRIVER_x86);
88+
if (hModule == NULL)
89+
hModule = GetModuleHandleA(DRIVER_x64);
90+
91+
if (hModule != NULL) {
92+
if (GetModuleFileNameA(hModule, modulePath, MAX_PATH) > 0) {
93+
94+
char tmpBuffer[MAX_PATH];
95+
sprintf_s(tmpBuffer, "%s\\..\\", modulePath);
96+
97+
GetFullPathNameA(tmpBuffer, MAX_PATH, modulePath, NULL);
98+
}
99+
}
100+
101+
if (isWin64) {
102+
// Must register both x86 and x64 dlls
103+
104+
// x64 registration
105+
GetSystemDirectoryA(systemPath, MAX_PATH);
106+
sprintf_s(cmdLine, "\"%s\\regsvr32.exe\" /s \"%s%s\"", systemPath, modulePath, DRIVER_x64);
107+
RunCommand(cmdLine);
108+
109+
// x86 registration
110+
fnGetSystemWow64Directory = (LPFN_GETSYSTEMWOW64DIRECTORY)GetProcAddress(
111+
GetModuleHandleA("kernel32"), "GetSystemWow64DirectoryA");
112+
fnGetSystemWow64Directory(systemPath, MAX_PATH);
113+
sprintf_s(cmdLine, "\"%s\\regsvr32.exe\" /s \"%s%s\"", systemPath, modulePath, DRIVER_x86);
114+
RunCommand(cmdLine);
115+
}
116+
else {
117+
// Register x86 only
118+
GetSystemDirectoryA(systemPath, MAX_PATH);
119+
sprintf_s(cmdLine, "\"%s\\regsvr32.exe\" /s \"%s%s\"", systemPath, modulePath, DRIVER_x64);
120+
RunCommand(cmdLine);
121+
122+
}
123+
124+
return S_OK;
125+
}

0 commit comments

Comments
 (0)