]> git.cameronkatri.com Git - ldid.git/commitdiff
Add Executable and Identifier to -h
authorCameron Katri <me@cameronkatri.com>
Thu, 7 Jul 2022 19:29:40 +0000 (15:29 -0400)
committerCameron Katri <me@cameronkatri.com>
Thu, 7 Jul 2022 19:29:40 +0000 (15:29 -0400)
.gitignore
ldid.cpp

index ba6a0f306f8db52fab920f889aff971a5bd13a12..e1bc11841d722de055f54cc0e3994b726f3a044e 100644 (file)
@@ -4,3 +4,4 @@ ldid
 .vscode
 compile_commands.json
 .cache
+*.core
index 5745e9b4f6943b44361f32e89226fdec88992c9b..24daf474595da31cd7387a5a57d8a375256e681b 100644 (file)
--- a/ldid.cpp
+++ b/ldid.cpp
@@ -3539,6 +3539,10 @@ int main(int argc, char *argv[]) {
             }
 
             if (flag_h) {
+                char *buf = _syscall(realpath(file.c_str(), NULL));
+                printf("Executable=%s\n", buf);
+                free(buf);
+
                 auto algorithms(GetAlgorithms());
 
                 uint32_t data = mach_header.Swap(signature->dataoff);
@@ -3552,6 +3556,7 @@ int main(int argc, char *argv[]) {
                     size_t size_;
                     Algorithm &algorithm_;
                     std::string hash_;
+                    uint32_t offset;
                 };
 
                 std::map<uint8_t, Candidate> candidates;
@@ -3567,7 +3572,7 @@ int main(int argc, char *argv[]) {
                         auto &algorithm(*algorithms[type - 1]);
                         uint8_t hash[algorithm.size_];
                         algorithm(hash, blob + begin, end - begin);
-                        candidates.insert({type, {directory, end - begin, algorithm, Hex(hash, 20)}});
+                        candidates.insert({type, {directory, end - begin, algorithm, Hex(hash, 20), begin}});
                     }
                 }
 
@@ -3578,6 +3583,8 @@ int main(int argc, char *argv[]) {
                 const auto directory(best->second.directory_);
                 const auto flags(Swap(directory->flags));
 
+                printf("Identifier=%s\n", blob + best->second.offset + Swap(directory->identOffset));
+
                 std::string names;
                 if (flags & kSecCodeSignatureHost)
                     names += ",host";