MCPcopy Create free account
hub / github.com/Vector35/debugger / InstallDbgEngRedistributable

Function InstallDbgEngRedistributable

ui/ui.cpp:126–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124 #include <Shlobj.h>
125
126static bool InstallDbgEngRedistributable()
127{
128 std::filesystem::path dbgEngPath;
129 if (getenv("BN_STANDALONE_DEBUGGER") != nullptr)
130 {
131 auto pluginsPath = BinaryNinja::GetUserPluginDirectory();
132 if (pluginsPath.empty())
133 return false;
134
135 auto path = std::filesystem::path(pluginsPath);
136 dbgEngPath = path / "dbgeng";
137 }
138 else
139 {
140 auto installPath = BinaryNinja::GetInstallDirectory();
141 if (installPath.empty())
142 return false;
143
144 auto path = std::filesystem::path(installPath);
145 dbgEngPath = path / "plugins" / "dbgeng";
146 }
147
148 if (!std::filesystem::exists(dbgEngPath))
149 {
150 LogWarn("path %d does not exists", dbgEngPath.string().c_str());
151 return false;
152 }
153
154 string cmdLine = "ACTION=ADMIN TARGETDIR=";
155
156 char appData[MAX_PATH];
157 if (!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, appData)))
158 return false;
159
160 auto debuggerRoot = filesystem::path(appData) / "Binary Ninja" / "dbgeng";
161 cmdLine = cmdLine + '"' + debuggerRoot.string() + '"';
162
163 auto x64Path = dbgEngPath / "X64 Debuggers And Tools-x64_en-us.msi";
164 auto ret = MsiInstallProductA(x64Path.string().c_str(), cmdLine.c_str());
165 if (ret != ERROR_SUCCESS)
166 return false;
167
168 auto x86Path = dbgEngPath / "X86 Debuggers And Tools-x86_en-us.msi";
169 ret = MsiInstallProductA((char*)x86Path.string().c_str(), cmdLine.c_str());
170 if (ret != ERROR_SUCCESS)
171 return false;
172
173 auto versionFilePath = debuggerRoot / "version.txt";
174 auto file = fopen(versionFilePath.string().c_str(), "w");
175 if (file == nullptr)
176 return false;
177
178 const char* DEBUGGER_REDIST_VERSION = "10.0.22621.1";
179 fwrite(DEBUGGER_REDIST_VERSION, 1, strlen(DEBUGGER_REDIST_VERSION), file);
180 fclose(file);
181 return true;
182}
183#endif

Callers 1

SetupMenuMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected