{"id":4383,"date":"2014-03-30T10:19:42","date_gmt":"2014-03-30T10:19:42","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/null-terminate-a-string-in-masm-getmodulefilename-collection-of-common-programming-errors\/"},"modified":"2014-03-30T10:19:42","modified_gmt":"2014-03-30T10:19:42","slug":"null-terminate-a-string-in-masm-getmodulefilename-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/null-terminate-a-string-in-masm-getmodulefilename-collection-of-common-programming-errors\/","title":{"rendered":"Null-terminate a string in MASM \/ GetModuleFileName-Collection of common programming errors"},"content":{"rendered":"<p>You need to add a zero to your variable at the end<\/p>\n<pre><code>.data\nszSrc db \"Your string\",0\n<\/code><\/pre>\n<p>if you need to do it at the runtime you need to get the Length of your variable (szSrc), then you could write somthing like this :<\/p>\n<pre><code>lea eax,szSrc\nmov byte ptr [eax+szSrcLen],0\n<\/code><\/pre>\n<p>Note : it is important to provide a valid Length .. , if you don&#8217;t know the correct string Length then it will be impossible to make a null string .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need to add a zero to your variable at the end .data szSrc db &#8220;Your string&#8221;,0 if you need to do it at the runtime you need to get the Length of your variable (szSrc), then you could write somthing like this : lea eax,szSrc mov byte ptr [eax+szSrcLen],0 Note : it is important [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4383","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4383"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4383\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}