{"id":9351,"date":"2024-08-07T21:59:28","date_gmt":"2024-08-07T21:59:28","guid":{"rendered":"https:\/\/www.hexacorn.com\/blog\/?p=9351"},"modified":"2024-08-07T22:56:36","modified_gmt":"2024-08-07T22:56:36","slug":"counting-the-api-arguments","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2024\/08\/07\/counting-the-api-arguments\/","title":{"rendered":"Counting the API arguments&#8230;"},"content":{"rendered":"\n<p>Today <a href=\"https:\/\/x.com\/scriptjunkie1\">Matt<\/a> posted a half-joking <a href=\"https:\/\/x.com\/scriptjunkie1\/status\/1821200450080670027\">twit<\/a> about the acceptable number of arguments that can be passed to a function&#8230;<\/p>\n\n\n\n<p>I took the challenge VERY SERIOUSLY and decided to investigate.<\/p>\n\n\n\n<p>In my <a href=\"https:\/\/www.hexacorn.com\/blog\/2023\/10\/25\/hunting-for-windows-api-prototypes-and-descriptions\/\" data-type=\"post\" data-id=\"8802\">old post<\/a> I shared my collections of API prototypes that I had extracted from various Microsoft documentation and other sources over the years; so my task was really easy &#8212; analyze this data and find the best candidate APIs that meet the criteria.<\/p>\n\n\n\n<p>I first looked at <em>2004-2007_apis.zip<\/em> file that included the number of arguments in one of the columns. After merging all this data into a single file, loading it to Excel, and sorting it in a descending order by the number of arguments I immediately <a href=\"https:\/\/x.com\/Hexacorn\/status\/1821203420155453679\">got <\/a>my first candidate: <\/p>\n\n\n\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-accesscheckbytyperesultlistandauditalarmbyhandlea\">AccessCheckByTypeResultListAndAuditAlarmByHandle<\/a><\/li>\n<\/ul>\n\n\n\n<p>It takes 17 arguments :-O <\/p>\n\n\n\n<p>I then looked at <em>2013_apis.zip<\/em> file as well &#8212; this time I had to write a simple script to parse the file and count number of arguments for each function and then save the results to a file. Same as before, I then loaded it to Excel, sored it in a descending order by the number of arguments and <a href=\"https:\/\/x.com\/Hexacorn\/status\/1821204489753317599\">now<\/a> I had my final candidate:<\/p>\n\n\n\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/dwrite\/nf-dwrite-idwritetextanalyzer-getgdicompatibleglyphplacements\">IDWriteTextAnalyzer::GetGdiCompatibleGlyphPlacements<\/a><\/li>\n<\/ul>\n\n\n\n<p>&#8211; it takes 21 arguments \ud83d\ude42<\/p>\n\n\n\n<p>Now, there may be other functions that take even more arguments as an input, but I bet they are quite rare. If you find one tough, please let me know and I will update this post.<\/p>\n\n\n\n<p><strong>Bonus<\/strong><\/p>\n\n\n\n<p>The longest api name I have ever encountered is this (1077 characters):<\/p>\n\n\n\n<ul>\n<li><em>ZN5boost12accumulators6detail14build_acc_listINS_6fusion12mpl_iteratorINS_3mpl6v_iterINS5_6v_itemINS1_19accumulator_wrapperINS0_4impl18lazy_variance_implIdNS0_3tag4meanEEENSB_13lazy_varianceEEENS7_INS8_INS9_11moment_implIN4mpl_4int_ILi2EEEdEENSB_6momentILi2EEEEENS7_INS8_INS9_11median_implIdEENSB_6medianEEENS7_INS8_INS9_22p_square_quantile_implIdNS0_10for_medianEEENSB_28p_square_quantile_for_medianEEENS7_INS8_INS9_8max_implIdEENSB_3maxEEENS7_INS8_INS9_9mean_implIdNSB_3sumEEESC_EENS7_INS8_INS9_8sum_implIdNSB_6sampleEEES12_EENS7_INS8_INS9_10count_implENSB_5countEEENS7_INS8_INS9_8min_implIdEENSB_3minEEENS5_7vector0INSH_2naEEELi0EEELi0EEELi0EEELi0EEELi0EEELi0EEELi0EEELi0EEELi0EEELl0EEEEENS4_INS6_IS1R_Ll9EEEEELb0EE4callINS_9parameter3aux8arg_listINS1Z_15tagged_argumentINSB_11accumulatorENS0_15accumulator_setIdNS0_5statsIS1E_SC_SZ_SQ_SE_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_S1H_EEvEEEENS1Z_14empty_arg_listEEEEENS3_4consIS1F_NS2A_IS1B_NS2A_IS18_NS2A_IS14_NS2A_IS10_NS2A_ISW_NS2A_ISR_NS2A_ISN_NS2A_ISF_NS3_3nilEEEEEEEEEEEEEEEEEEERKT_RKS1T_RKS1V<\/em><\/li>\n<\/ul>\n\n\n\n<p>it&#8217;s from the sample: <\/p>\n\n\n\n<ul>\n<li>8005F35D2C2642B33ADB77CBD100BF64CC7DB611FA789AE18BFFF3F91B26AB40_4E8BA4874E4D7B99C0BDF31EFBB4051DCDB2F29D<\/li>\n<\/ul>\n\n\n\n<p>Additionally, the API name that includes the most words in it (11) is:<\/p>\n\n\n\n<ul>\n<li>AccessCheckByTypeResultListAndAuditAlarmByHandle<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Today Matt posted a half-joking twit about the acceptable number of arguments that can be passed to a function&#8230; I took the challenge VERY SERIOUSLY and decided to investigate. In my old post I shared my collections of API prototypes &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2024\/08\/07\/counting-the-api-arguments\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[53,18],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9351"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=9351"}],"version-history":[{"count":4,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9351\/revisions"}],"predecessor-version":[{"id":9357,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9351\/revisions\/9357"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=9351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=9351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=9351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}