<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; WSH: патч бинарного файла]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=239&amp;type=atom" />
	<updated>2006-12-12T08:45:13Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=239</id>
		<entry>
			<title type="html"><![CDATA[WSH: патч бинарного файла]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=1267#p1267" />
			<content type="html"><![CDATA[<p>Скрипт делает патч для бинарного файла, если известно смещение и известно, какое число записать в шестнадцатеричном виде в нужный байт:<br /></p><div class="codebox"><pre><code>&lt;job&gt;
 &lt;script language=&quot;JScript&quot;&gt;

  var file=WSH.arguments(0),position=WSH.arguments(1),byte=eval(&quot;&#039;&quot;+WSH.arguments(2)+&quot;&#039;&quot;);

  var inp=new ActiveXObject(&quot;ADODB.Stream&quot;);
      inp.Type=1;
      inp.Open();
      inp.LoadFromFile(file);

  var out=new ActiveXObject(&quot;ADODB.Stream&quot;);
      out.Type=1;
      out.Open();

  inp.CopyTo(out,position*1);
  inp.Read(1);
  out.Write(mb2b(byte));
  inp.CopyTo(out);

  out.SaveToFile(file+&quot;.out&quot;,2);

 // ----------------------------------------

 function mb2b(byte)
 {
  with(new ActiveXObject(&quot;ADODB.Recordset&quot;))
  {
   Fields.Append(&quot;x&quot;,205,1);
   Open();
   AddNew();
   Fields(0).AppendChunk(byte);
   return Fields(0).GetChunk(1);
  }
 }

 &lt;/script&gt;
&lt;/job&gt;</code></pre></div><p>Сохраните вышеприведённый код в файле с расширением .wsf.<br />Автор скрипта - <strong>fps</strong>.<br />Использование: <strong>patch.wsf inputFilename position byte</strong><br />Пример использования в командной строке:<br /></p><div class="codebox"><pre><code>C:\&gt;patch.wsf Notepad.exe 0xAB \xFF
C:\&gt;fc /b Notepad.exe Notepad.exe.out
Сравнение файлов Notepad.exe и NOTEPAD.EXE.OUT
000000AB: F2 FF</code></pre></div><p>Смещение можно указывать как в десятичном, так и в hex-виде.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2006-12-12T08:45:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=1267#p1267</id>
		</entry>
</feed>
