@@ -1526,32 +1526,84 @@ int main(int argc, char* argv[])
1526
1526
{
1527
1527
char *pName;
1528
1528
char *fileName;
1529
+ char *fileNameWithFunctionNames;
1529
1530
SYMBOL_INFO *pSymbolList;
1531
+ int argvOffset = 0 ;
1532
+ bool useFile = false ;
1530
1533
1531
1534
if (argc < 5 ) {
1532
- printf (" Not enough arguments: 64/32 dllname filename.lib funcname1 funcname2 etc\n " );
1535
+ printf (" Expected arguments: 64/32 dllname filename.lib funcname1 funcname2 etc\n " );
1536
+ printf (" Alternatively: file 64/32 dllname filename.lib funcnames.txt\n " );
1533
1537
fflush (0 );
1534
1538
exit (123 );
1535
1539
}
1536
1540
1541
+ // `file`
1542
+ if (argv[argvOffset + 1 ][0 ] == ' f' ) {
1543
+ useFile = true ;
1544
+ argvOffset++;
1545
+ }
1546
+
1537
1547
g_InfoAll.bX64 = TRUE ;
1538
- if (argv[1 ][0 ] == ' 3' ) {
1548
+ // `32`
1549
+ if (argv[argvOffset + 1 ][0 ] == ' 3' ) {
1539
1550
g_InfoAll.bX64 = FALSE ;
1540
1551
}
1541
1552
1542
- pName = " long_dll_name_long_dll_name_long_dll_name" ;
1543
- pName = argv[2 ];
1544
- fileName = argv[3 ];
1553
+ pName = argv[argvOffset + 2 ];
1554
+ fileName = argv[argvOffset + 3 ];
1545
1555
1546
1556
pSymbolList = CreateSymbolList (pName);
1547
1557
1558
+ if (useFile) {
1559
+ fileNameWithFunctionNames = argv[argvOffset + 4 ];
1560
+
1561
+ FILE *file = fopen (fileNameWithFunctionNames, " r" );
1562
+ if (file == 0 ) {
1563
+ printf (" Failed to open file %s\n " , fileNameWithFunctionNames);
1564
+ fflush (0 );
1565
+ exit (2 );
1566
+ }
1567
+ fseek (file, 0 , SEEK_END);
1568
+ int fileSize = ftell (file);
1569
+ rewind (file);
1570
+
1571
+ char *pFileContents = new char [fileSize + 1 ];
1572
+ fread (pFileContents, 1 , fileSize, file);
1573
+ fclose (file);
1574
+ pFileContents[fileSize] = 0 ; // null-terminate
1575
+
1576
+ int i = 0 ;
1577
+ while (pFileContents[i] != 0 && i < fileSize) {
1578
+ char *pBegin = pFileContents + i;
1579
+ // Both spaces and enters work
1580
+ while (
1581
+ pFileContents[i] != 0
1582
+ && pFileContents[i] != ' \n '
1583
+ && pFileContents[i] != ' '
1584
+ ) {
1585
+ i++;
1586
+ }
1587
+ int len = i - (pBegin - pFileContents);
1588
+ if (len == 0 ) {
1589
+ break ;
1590
+ }
1591
+ char *pFuncName = new char [len + 1 ];
1592
+ memcpy (pFuncName, pBegin, len);
1593
+ pFuncName[len] = 0 ;
1594
+ // printf("AddFunction from file: `%s`\n", pFuncName);
1595
+ AddFunction (pSymbolList, pFuncName, 0 , 0 , CALLING_CONVENTION_UNDECORATED, IMPORT_BY_DECORATED_NAME);
1596
+ i++;
1597
+ }
1598
+ } else {
1548
1599
int i = 4 ;
1549
1600
while (i < argc) {
1550
- AddFunction (pSymbolList, argv[i], 0 , 0 , CALLING_CONVENTION_UNDECORATED, IMPORT_BY_DECORATED_NAME);
1601
+ AddFunction (pSymbolList, argv[argvOffset + i], 0 , 0 , CALLING_CONVENTION_UNDECORATED, IMPORT_BY_DECORATED_NAME);
1551
1602
// TODO add verbose mode
1552
1603
// printf("AddFunction %s\n", argv[i]);
1553
1604
i++;
1554
1605
}
1606
+ }
1555
1607
1556
1608
fflush (0 );
1557
1609
// AddFunction(pSymbolList, "function100", 0, 0, CALLING_CONVENTION_STDCALL, IMPORT_BY_DECORATED_NAME);
0 commit comments