Skip to content

Commit

Permalink
Fix IDA Pro 9.0+ Right Click Open
Browse files Browse the repository at this point in the history
  • Loading branch information
emtuls committed Nov 7, 2024
1 parent 0f526b9 commit 3017f3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
Binary file modified ida_launcher/ida_launcher.exe
Binary file not shown.
36 changes: 23 additions & 13 deletions ida_launcher/src/ida_launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int findHighestIdaVersion(HKEY rootKey, LPCSTR subKey, LPCSTR idaIdentifier, LPS
int highestMajor = -1, highestMinor = -1;
BOOL found = FALSE;

lRes = RegOpenKeyExA(rootKey, subKey, 0, KEY_READ, &hKey);
lRes = RegOpenKeyExA(rootKey, subKey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
if (lRes != ERROR_SUCCESS) {
return 0; // Unable to open registry key
}
Expand All @@ -30,20 +30,19 @@ int findHighestIdaVersion(HKEY rootKey, LPCSTR subKey, LPCSTR idaIdentifier, LPS
DWORD dwKeyNameSize = sizeof(keyName);
lRes = RegEnumKeyExA(hKey, dwIndex, keyName, &dwKeyNameSize, NULL, NULL, NULL, NULL);
if (lRes != ERROR_SUCCESS) {
break; // No more keys or an error occurred
break; // Exit the loop on error
}

HKEY hSubKey;
lRes = RegOpenKeyExA(hKey, keyName, 0, KEY_READ, &hSubKey);
if (lRes == ERROR_SUCCESS) {
DWORD displayNameSize = sizeof(displayName);
lRes = RegQueryValueExA(hSubKey, "DisplayName", NULL, NULL, (LPBYTE)displayName, &displayNameSize);
char errorMessage[256];
if (lRes == ERROR_SUCCESS && strstr(displayName, idaIdentifier) != NULL) {
DWORD majorVersion = 0, minorVersion = 0;
DWORD majorSize = sizeof(majorVersion), minorSize = sizeof(minorVersion);
RegQueryValueExA(hSubKey, "MajorVersion", NULL, NULL, (LPBYTE)&majorVersion, &majorSize);
RegQueryValueExA(hSubKey, "MinorVersion", NULL, NULL, (LPBYTE)&minorVersion, &minorSize);

if (compareVersions(majorVersion, minorVersion, highestMajor, highestMinor) > 0) {
highestMajor = majorVersion;
highestMinor = minorVersion;
Expand All @@ -56,7 +55,6 @@ int findHighestIdaVersion(HKEY rootKey, LPCSTR subKey, LPCSTR idaIdentifier, LPS
}
dwIndex++;
}

RegCloseKey(hKey);
return found;
}
Expand All @@ -66,17 +64,29 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
char idaPath[260] = {0};
DWORD dwSize = sizeof(idaPath);

// Search for the highest version of IDA Pro first
if (!findHighestIdaVersion(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "IDA Pro", idaPath, dwSize)) {
// If IDA Pro not found, search for the highest version of IDA Freeware
if (!findHighestIdaVersion(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "IDA Freeware", idaPath, dwSize)) {
MessageBox(NULL, "IDA not found.", "Error", MB_OK | MB_ICONERROR);
return 1;
// Search for the highest version of IDA Pro first (version 9.0+ uses "IDA Professional")
if (!findHighestIdaVersion(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "IDA Professional", idaPath, dwSize)) {
if (!findHighestIdaVersion(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "IDA Pro", idaPath, dwSize)) {
// If IDA Pro not found, search for the highest version of IDA Freeware
if (!findHighestIdaVersion(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "IDA Freeware", idaPath, dwSize)) {
MessageBox(NULL, "IDA not found.", "Error", MB_OK | MB_ICONERROR);
return 1;
}
}
}

// Append ida64.exe to the path
strcat(idaPath, "\\ida64.exe");
// Construct the path with ida64.exe
char idaPath64[260];
strcpy(idaPath64, idaPath);
strcat(idaPath64, "\\ida64.exe");

// Check if ida64.exe exists
if (GetFileAttributesA(idaPath64) != INVALID_FILE_ATTRIBUTES) {
strcpy(idaPath, idaPath64); // Use ida64.exe if it exists
} else {
// If ida64.exe doesn't exist, use ida.exe
strcat(idaPath, "\\ida.exe");
}

// Check if a file path is provided as an argument
if (strlen(lpCmdLine) > 0) {
Expand Down

0 comments on commit 3017f3a

Please sign in to comment.