Skip to content

Commit

Permalink
Finishing setup implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroasm committed Jan 6, 2017
1 parent 45eb210 commit ef260b9
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 798 deletions.
712 changes: 0 additions & 712 deletions DriverInstaller-x64/DriverInstaller-x64.vdproj

This file was deleted.

146 changes: 76 additions & 70 deletions DriverInstaller/DriverInstaller.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"VSVersion" = "3:800"
"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}"
"IsWebType" = "8:FALSE"
"ProjectName" = "8:DriverInstaller-x86"
"ProjectName" = "8:DriverInstaller"
"LanguageId" = "3:1033"
"CodePage" = "3:1252"
"UILanguageId" = "3:1033"
Expand All @@ -13,6 +13,12 @@
"SccProvider" = "8:"
"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_C378259A8D8C4FB880EAEC27ECC1720F"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_CACB481DB8B74D96B26F50DCA0C3F56A"
Expand All @@ -27,7 +33,7 @@
"DisplayName" = "8:Debug"
"IsDebugOnly" = "11:TRUE"
"IsReleaseOnly" = "11:FALSE"
"OutputFilename" = "8:Debug\\DriverInstaller.msi"
"OutputFilename" = "8:..\\Release\\VibrationDriverInstaller.msi"
"PackageFilesAs" = "3:2"
"PackageFileSize" = "3:-2147483648"
"CabType" = "3:1"
Expand All @@ -37,13 +43,21 @@
"PrivateKeyFile" = "8:"
"TimeStampServer" = "8:"
"InstallerBootstrapper" = "3:2"
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
{
"Enabled" = "11:TRUE"
"PromptEnabled" = "11:TRUE"
"PrerequisitesLocation" = "2:1"
"Url" = "8:"
"ComponentsUrl" = "8:"
}
}
"Release"
{
"DisplayName" = "8:Release"
"IsDebugOnly" = "11:FALSE"
"IsReleaseOnly" = "11:TRUE"
"OutputFilename" = "8:..\\Release\\VibrationDriverInstaller-x86.msi"
"OutputFilename" = "8:..\\Release\\VibrationDriverInstaller.msi"
"PackageFilesAs" = "3:2"
"PackageFileSize" = "3:-2147483648"
"CabType" = "3:1"
Expand All @@ -70,6 +84,20 @@
{
"CustomAction"
{
"{4AA51A2D-7D85-4A59-BA75-B0809FC8B380}:_A58FBA840C67404E868C9D92987CA01A"
{
"Name" = "8:GenericFFBDriver32.dll"
"Condition" = "8:"
"Object" = "8:_CACB481DB8B74D96B26F50DCA0C3F56A"
"FileType" = "3:1"
"InstallAction" = "3:1"
"Arguments" = "8:"
"EntryPoint" = "8:RegisterVibrationDriver"
"Sequence" = "3:1"
"Identifier" = "8:_E9FCB57E_3CD7_4256_8EE5_1BFB7014D07D"
"InstallerClass" = "11:FALSE"
"CustomActionData" = "8:"
}
}
"DefaultFeature"
{
Expand All @@ -85,12 +113,32 @@
}
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C378259A8D8C4FB880EAEC27ECC1720F"
{
"SourcePath" = "8:..\\Release\\GenericFFBDriver64.dll"
"TargetName" = "8:GenericFFBDriver64.dll"
"Tag" = "8:"
"Folder" = "8:_08365EDD8FF742F7A8EA90AD36CEE015"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CACB481DB8B74D96B26F50DCA0C3F56A"
{
"SourcePath" = "8:..\\Release\\GenericFFBDriver32.dll"
"TargetName" = "8:GenericFFBDriver32.dll"
"Tag" = "8:"
"Folder" = "8:_70D2A39DB17244D1A08BF53BE196346B"
"Folder" = "8:_08365EDD8FF742F7A8EA90AD36CEE015"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
Expand Down Expand Up @@ -145,16 +193,31 @@
{
}
}
"{1525181F-901A-416C-8A58-119130FE478E}:_EB20EB274A8046AEA4621B3A08C74E43"
{
"Name" = "8:#1924"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:WindowsFolder"
"Folders"
{
"{9EF0B969-E518-4E46-987F-47570745A589}:_08365EDD8FF742F7A8EA90AD36CEE015"
{
"Name" = "8:GenericFFBDriver"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:_C4024A52445545BFAFDC66ED44DCA719"
"Folders"
{
}
}
}
}
}
"LaunchCondition"
{
"{836E08B8-0285-4809-BA42-01DB6754A45D}:_CE465BB9F91247E294E9C0235D4ECCAC"
{
"Name" = "8:Machine_is_x64"
"Condition" = "8:!VersionNT64"
"Message" = "8:Please install the x64 driver"
"InstallUrl" = "8:"
}
}
"Locator"
{
Expand All @@ -169,15 +232,15 @@
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Generic USB Gamepad Vibration Driver"
"ProductCode" = "8:{50CD8B4D-CD82-49D1-9E0A-2B7887448068}"
"PackageCode" = "8:{9637050A-F0CF-4529-95D3-3BD9C8410FAB}"
"PackageCode" = "8:{C6059427-7868-44F2-86B6-E029402B5181}"
"UpgradeCode" = "8:{A08375A2-DC94-4A88-8431-ED8D9717FA62}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:FALSE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.0.0"
"Manufacturer" = "8:Alessandro Menezes"
"Manufacturer" = "8:Generic USB Gamepad Vibration Driver"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
"Title" = "8:Generic USB Gamepad Vibration Driver"
Expand Down Expand Up @@ -494,28 +557,6 @@
}
}
}
"{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_F2DB315D6C9C45D2BEFEDAE1DE489358"
{
"Sequence" = "3:200"
"DisplayName" = "8:Installation Folder"
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:FALSE"
"SourcePath" = "8:<VsdDialogDir>\\VsdAdminFolderDlg.wid"
"Properties"
{
"BannerBitmap"
{
"Name" = "8:BannerBitmap"
"DisplayName" = "8:#1001"
"Description" = "8:#1101"
"Type" = "3:8"
"ContextData" = "8:Bitmap"
"Attributes" = "3:4"
"Setting" = "3:1"
"UsePlugInResources" = "11:TRUE"
}
}
}
}
}
"{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_781D1A01A61242E48BB1652DE8A42A73"
Expand Down Expand Up @@ -575,41 +616,6 @@
"Attributes" = "3:1"
"Dialogs"
{
"{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_D2E3044385814E558FB3996F30200A15"
{
"Sequence" = "3:200"
"DisplayName" = "8:Installation Folder"
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:FALSE"
"SourcePath" = "8:<VsdDialogDir>\\VsdFolderDlg.wid"
"Properties"
{
"BannerBitmap"
{
"Name" = "8:BannerBitmap"
"DisplayName" = "8:#1001"
"Description" = "8:#1101"
"Type" = "3:8"
"ContextData" = "8:Bitmap"
"Attributes" = "3:4"
"Setting" = "3:1"
"UsePlugInResources" = "11:TRUE"
}
"InstallAllUsersVisible"
{
"Name" = "8:InstallAllUsersVisible"
"DisplayName" = "8:#1059"
"Description" = "8:#1159"
"Type" = "3:5"
"ContextData" = "8:1;True=1;False=0"
"Attributes" = "3:0"
"Setting" = "3:0"
"Value" = "3:1"
"DefaultValue" = "3:1"
"UsePlugInResources" = "11:TRUE"
}
}
}
"{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_DD51DDF859CE471FA216BD8D94DC9BF2"
{
"Sequence" = "3:300"
Expand Down
3 changes: 3 additions & 0 deletions GenericFFBDriver/GenericFFBDriver.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;GENERICFFBDRIVER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down Expand Up @@ -127,6 +128,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GENERICFFBDRIVER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down Expand Up @@ -189,6 +191,7 @@
<ClCompile Include="FFBDriver.cpp" />
<ClCompile Include="GenericFFBDriver.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="VibrationDriverRegistration.cpp" />
<ClCompile Include="vibration\VibrationController.cpp" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions GenericFFBDriver/GenericFFBDriver.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<ClCompile Include="vibration\VibrationController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VibrationDriverRegistration.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="genericFFBDriver.def">
Expand Down
125 changes: 125 additions & 0 deletions GenericFFBDriver/VibrationDriverRegistration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#include "stdafx.h"
#include <fstream>
#include <filesystem>

#define DRIVER_x86 "GenericFFBDriver32.dll"
#define DRIVER_x64 "GenericFFBDriver64.dll"

#ifdef _WIN64
#define IS_WIN64 TRUE
#else
#define IS_WIN64 IsWow64()
#endif

typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process;

typedef UINT(WINAPI *LPFN_GETSYSTEMWOW64DIRECTORY) (LPSTR, UINT);
LPFN_GETSYSTEMWOW64DIRECTORY fnGetSystemWow64Directory;

BOOL IsWow64()
{
BOOL bIsWow64 = FALSE;

//IsWow64Process is not available on all supported versions of Windows.
//Use GetModuleHandle to get a handle to the DLL that contains the function
//and GetProcAddress to get a pointer to the function if available.

fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
GetModuleHandle(TEXT("kernel32")), "IsWow64Process");

if (NULL != fnIsWow64Process)
{
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());

_ASSERT(hr == S_OK);
}
}
return bIsWow64;
}


int RunCommand(LPSTR cmd) {
STARTUPINFOA si;
PROCESS_INFORMATION pi;

ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));

// Start the child process.
if (!CreateProcessA(NULL, // No module name (use command line)
cmd, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
printf("CreateProcess failed (%d).\n", GetLastError());
return FALSE;
}

// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE);

// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

return TRUE;
}

STDAPI RegisterVibrationDriver(void) {
BOOL isWin64 = IS_WIN64;
char systemPath[MAX_PATH];
char cmdLine[MAX_PATH];
char modulePath[MAX_PATH];

// Finding dll directory
strcpy_s(modulePath, "");

HMODULE hModule = GetModuleHandleA(DRIVER_x86);
if (hModule == NULL)
hModule = GetModuleHandleA(DRIVER_x64);

if (hModule != NULL) {
if (GetModuleFileNameA(hModule, modulePath, MAX_PATH) > 0) {

char tmpBuffer[MAX_PATH];
sprintf_s(tmpBuffer, "%s\\..\\", modulePath);

GetFullPathNameA(tmpBuffer, MAX_PATH, modulePath, NULL);
}
}

if (isWin64) {
// Must register both x86 and x64 dlls

// x64 registration
GetSystemDirectoryA(systemPath, MAX_PATH);
sprintf_s(cmdLine, "\"%s\\regsvr32.exe\" /s \"%s%s\"", systemPath, modulePath, DRIVER_x64);
RunCommand(cmdLine);

// x86 registration
fnGetSystemWow64Directory = (LPFN_GETSYSTEMWOW64DIRECTORY)GetProcAddress(
GetModuleHandleA("kernel32"), "GetSystemWow64DirectoryA");
fnGetSystemWow64Directory(systemPath, MAX_PATH);
sprintf_s(cmdLine, "\"%s\\regsvr32.exe\" /s \"%s%s\"", systemPath, modulePath, DRIVER_x86);
RunCommand(cmdLine);
}
else {
// Register x86 only
GetSystemDirectoryA(systemPath, MAX_PATH);
sprintf_s(cmdLine, "\"%s\\regsvr32.exe\" /s \"%s%s\"", systemPath, modulePath, DRIVER_x64);
RunCommand(cmdLine);

}

return S_OK;
}
Loading

0 comments on commit ef260b9

Please sign in to comment.