-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: crash when guid can't be parsed (#55)
- Loading branch information
Showing
5 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { PdbFile, PeFile } from 'pdb-guid'; | ||
|
||
export async function tryGetPdbGuid(pdbFilePath: string): Promise<string> { | ||
try { | ||
const pdbFile = await PdbFile.createFromFile(pdbFilePath); | ||
return `${pdbFile.guid}`; | ||
} catch (error) { | ||
console.log(`Could not get guid for ${pdbFilePath}...`); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
export async function tryGetPeGuid(peFilePath: string): Promise<string> { | ||
try { | ||
const pdbFile = await PeFile.createFromFile(peFilePath); | ||
return `${pdbFile.guid}`; | ||
} catch (error) { | ||
console.log(`Could not get guid for ${peFilePath}...`); | ||
} | ||
|
||
return ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { tryGetPdbGuid, tryGetPeGuid } from '../bin/pdb'; | ||
|
||
describe('pdb', () => { | ||
describe('tryGetPdbGuid', () => { | ||
it('should return guid for c++ pdb', async () => { | ||
return expectAsync(tryGetPdbGuid('spec/support/bugsplat.pdb')).toBeResolvedTo('E546B55B6D214E86871B40AC35CD0D461'); | ||
}); | ||
|
||
it('should return empty guid for unrecognized pdb', () => { | ||
return expectAsync(tryGetPdbGuid('spec/support/portable.pdb')).toBeResolvedTo(''); | ||
}); | ||
}); | ||
|
||
describe('tryGetPeGuid', () => { | ||
it('should return guid for c++ exe', () => { | ||
return expectAsync(tryGetPeGuid('spec/support/bssndrpt.exe')).toBeResolvedTo('64FB82D565000'); | ||
}); | ||
|
||
it('should return empty guid for unrecognized pe file', () => { | ||
return expectAsync(tryGetPeGuid('spec/support/corrupt.exe')).toBeResolvedTo(''); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
not an exe! |
Binary file not shown.