espetoet

Untitled

Oct 9th, 2019
461
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ;-------------------------------
  3. AHK source code Encryptor v2.7 By FeiYue
  4.  
  5. 1. This tool can encrypt the AHK script into a self decode script.
  6.  
  7. 2. Then you can use ahk2exe to compile the script into a program,
  8. combined with mpress.exe or upx.exe packers.
  9. Note: To compile the script, you must have a AutoHotkey.exe
  10. in the script directory.
  11.  
  12. 3. When you want to use the directory relative to the script(eg 001.jpg),
  13. Don't use A_ScriptDir, but use A_WorkingDir. It is recommended to backup
  14. the working directory to a variable at the beginning of the script,
  15. Then change the path to absolute path based on the variable (eg %dir%\001.jpg).
  16.  
  17. 4. When you want to Reload your own script, the built-in Reload command will fail,
  18. You can use Reload() function instead (it's added when encrypted).
  19.  
  20. ;-------------------------------
  21. */
  22.  
  23. #NoEnv
  24. #SingleInstance force
  25. ListLines, Off
  26. SetBatchLines, -1
  27. Version = 2.7
  28.  
  29. fs=
  30. (` %
  31.  
  32. Exec(str, Ahk="", arg="") {
  33. static MyFunc, base, ScriptName:=%True%
  34. s:=RegExReplace(str,"\s"), StrReplace(s,"u","",size)
  35. VarSetCapacity(str,(size+1)*4,0), s:=SubStr(s,InStr(s,"u")+1)
  36. Loop, Parse, s, u
  37. NumPut(A_LoopField, str, (A_Index-1)*4, "uint")
  38. ;-----------------------------
  39. Ahk:=Ahk ? Ahk : A_IsCompiled
  40. ? A_ScriptDir "\AutoHotkey.exe" : A_AhkPath
  41. IfNotExist, %Ahk%
  42. {
  43. MsgBox, 4096, Error!, `n`nCan't Find: %Ahk% !`n`n
  44. return, 0
  45. }
  46. if !MyFunc
  47. {
  48. x32:="5557565381EC4C0100008B9C24680100008BBC246C01000"
  49. . "08BAC24700100008B433C01D88038500F85380500008078014"
  50. . "50F852E0500008B706085F60F84FF04000031C9837864010F9"
  51. . "2C119D283E210894C245083C2788B341001DE8B4E188974243"
  52. . "C8B562085C90F84E504000031C08D3413EB0B83C00139C10F8"
  53. . "4D30400008B1486813C134765745075E9817C1304726F63417"
  54. . "5DF8B74243C8D04430346240FB7008D048303461C8B3085F60"
  55. . "F84A0040000B86500000001DE891C2466894424688D442460C"
  56. . "744246057726974C74424646546696C89442404FFD683EC088"
  57. . "944243C8D442475891C24C7442475476C6F62C7442479616C4"
  58. . "16CC744247D6C6F630089442404FFD683EC08BA65650000894"
  59. . "424548D44246A6689542472891C24C744246A476C6F62C7442"
  60. . "46E616C4672C64424740089442404FFD683EC08B9734100008"
  61. . "94424488D84248D00000066898C2499000000891C24C784248"
  62. . "D00000043726561C784249100000074655072C784249500000"
  63. . "06F636573C684249B0000000089442404FFD683EC088944245"
  64. . "C8D8424BE000000891C24C78424BE00000043726561C78424C"
  65. . "200000074654E61C78424C60000006D656450C78424CA00000"
  66. . "069706541C68424CE0000000089442404FFD683EC088944245"
  67. . "88D8424CF000000891C24C78424CF000000436F6E6EC78424D"
  68. . "30000006563744EC78424D7000000616D6564C78424DB00000"
  69. . "050697065C68424DF0000000089442404FFD683EC088944244"
  70. . "08D842481000000891C24C7842481000000436C6F73C784248"
  71. . "50000006548616EC7842489000000646C650089442404FFD68"
  72. . "3EC088D5C24608944244CC744241000000000C744240800000"
  73. . "000897C2404895C240CC7042400000000FF54243C83EC14807"
  74. . "C2460000F85E50200008D34AD04000000C7042400000000897"
  75. . "4244489742404FF54245483EC0885C089C30F841703000031C"
  76. . "085ED7415908B148789148383C00139C575F38B44244483E80"
  77. . "4C7040300000000C784249C0000000B000000BA0B000000C78"
  78. . "424A00000000D000000C78424A40000001100000031C0C7842"
  79. . "4A800000013000000EB0C89C283E2038B94949C00000069D28"
  80. . "300000089C183E10301C283C00183F86489948C9C00000075D"
  81. . "831D285ED742D669089D183E10369848C9C000000830000000"
  82. . "1D089848C9C000000330493D1C083C00189049383C20139D57"
  83. . "5D58B8424640100008B742458C744241C00000000C74424180"
  84. . "0000000C744241400000000C744241000000000C744240CFF0"
  85. . "00000C744240800000000C744240402000000890424FFD683E"
  86. . "C2089C78B842464010000C744241C00000000C744241800000"
  87. . "000C744241400000000C744241000000000C744240CFF00000"
  88. . "0C744240800000000C744240402000000890424FFD683EC208"
  89. . "3FFFF89C60F849D01000083F8FF0F84940100008D8C24E0000"
  90. . "0008D94244001000089C8C7000000000083C00439C275F3837"
  91. . "C245001894C2420C744241C00000000C744241800000000C74"
  92. . "4241400000000C744241000000000C744240C00000000C7442"
  93. . "4080000000019C0C704240000000083E0E483C060898424E00"
  94. . "000008D8424AC000000894424248B84246001000089442404F"
  95. . "F54245C83EC2885C00F84DA0000008B6C244C8B8424AC00000"
  96. . "089042489E8FFD083EC048B8424B000000089042489E8FFD08"
  97. . "3EC04893C24C744240400000000FF54244083EC0889E8893C2"
  98. . "4FFD083EC04893424C744240400000000FF54244083EC088D4"
  99. . "42460895C2404893424C7442410000000008944240C8B44244"
  100. . "489442408FF54243C83EC1489E8893424FFD083EC04891C24F"
  101. . "F54244883EC0431C081C44C0100005B5E5F5DC21400C744245"
  102. . "001000000BA88000000E904FBFFFFB8FEFFFFFF81C44C01000"
  103. . "05B5E5F5DC2140081C44C010000B8FFFFFFFF5B5E5F5DC2140"
  104. . "0B8FDFFFFFFEBDA893C248B7C244C89F8FFD083EC0489F8893"
  105. . "424FFD083EC04891C24FF542448B8FAFFFFFF83EC04EBB1893"
  106. . "C248B7C244C89F8FFD083EC0489F8893424FFD083EC04891C2"
  107. . "4FF542448B8FBFFFFFF83EC04EB88B8FCFFFFFFEB8190"
  108. x64:="4157415641554154555756534881EC98010000B8FFFFFFF"
  109. . "F8BB4240002000048899424E8010000418B503C4D89C748898"
  110. . "C24E00100004D89CC4C01C2803A500F858C040000807A01450"
  111. . "F8582040000448B42604585C00F8489040000837A64014819C"
  112. . "031FF83E0104883C078837A6401400F92C7897C245C448B0C0"
  113. . "2B8FEFFFFFF4D01F9418B4918418B512085C90F843D0400003"
  114. . "1C04D8D0417EB100F1F40004883C00139C10F864B040000418"
  115. . "B148041813C174765745075E641817C1704726F634175DB418"
  116. . "B5124498D04470FB71410418B411C498D14978B3C0285FF0F8"
  117. . "41304000048B8577269746546696C488D6C24704C01FF48894"
  118. . "42470B8650000004C89F94889EA6689442478FFD74989C548B"
  119. . "8476C6F62616C416C488D9424900000004C89F948898424900"
  120. . "00000C78424980000006C6F6300FFD7BA656500004889C348B"
  121. . "8476C6F62616C467266899424880000004C89F9488D9424800"
  122. . "000004889842480000000C684248A00000000FFD7B97341000"
  123. . "0488944245048B8437265617465507266898C24BC000000488"
  124. . "D9424B00000004C89F948898424B0000000C78424B80000006"
  125. . "F636573C68424BE00000000FFD7488944246048B8437265617"
  126. . "4654E61488D9424D000000048898424D000000048B86D65645"
  127. . "0697065414C89F948898424D8000000C68424E000000000FFD"
  128. . "74989C648B8436F6E6E6563744E488D9424F00000004889842"
  129. . "4F000000048B8616D6564506970654C89F948898424F800000"
  130. . "0C684240001000000FFD7488944246848B8436C6F736548616"
  131. . "E488D9424A00000004C89F948898424A0000000C78424A8000"
  132. . "000646C6500FFD74531C031C94889C748C7442420000000004"
  133. . "989E94C89E241FFD5807C247000B8FDFFFFFF0F85490200008"
  134. . "D14B50400000031C94989D7FFD34885C04889C30F849202000"
  135. . "031C085F6741D0F1F840000000000418B14848914834883C00"
  136. . "139C677F189F048C1E002C7040300000000C78424C00000000"
  137. . "B000000BA0B000000C78424C40000000D000000C78424C8000"
  138. . "0001100000031C0C78424CC00000013000000EB0C89C283E20"
  139. . "38B9494C000000069D28300000089C183E10301C283C00183F"
  140. . "86489948CC000000075D831D285F6742E904889D183E103698"
  141. . "48CC00000008300000001D089848CC0000000330493D1C083C"
  142. . "0018904934883C20139D677D34531C041B9FF000000BA02000"
  143. . "000488B8C24E801000048C744243800000000C744243000000"
  144. . "000C744242800000000C74424200000000041FFD64889C6453"
  145. . "1C048C744243800000000C744243000000000C744242800000"
  146. . "00041B9FF000000C744242000000000BA02000000488B8C24E"
  147. . "801000041FFD64883FEFF4989C40F84380100004883F8FF0F8"
  148. . "42E010000488D8C2430010000488D9424900100004889C8669"
  149. . "0C700000000004883C0044839C275F1837C245C0148894C244"
  150. . "048C74424380000000048C744243000000000C744242800000"
  151. . "000C744242000000000488B9424E001000019C04531C94531C"
  152. . "083E0E431C983C06089842430010000488D842410010000488"
  153. . "9442448488B442460FFD085C00F8488000000488B8C2410010"
  154. . "000FFD7488B8C2418010000FFD74C8B74246831D24889F14C8"
  155. . "9F0FFD04889F1FFD731D24C89E14C89F0FFD04989E94589F84"
  156. . "889DA4C89E148C74424200000000041FFD54C89E1FFD74889D"
  157. . "9488B442450FFD031C04881C4980100005B5E5F5D415C415D4"
  158. . "15E415FC3B888000000C744245C01000000E981FBFFFFB8FEF"
  159. . "FFFFFEBD34889F1FFD74C89E1FFD74889D9488B442450FFD0B"
  160. . "8FAFFFFFFEBB84889F1FFD74C89E1FFD74889D9488B442450F"
  161. . "FD0B8FBFFFFFFEB9DB8FCFFFFFFEB969090909090"
  162. hex:=A_PtrSize=8 ? x64:x32
  163. VarSetCapacity(MyFunc, len:=StrLen(hex)//2)
  164. Loop, % len
  165. NumPut("0x" SubStr(hex,2*A_Index-1,2),MyFunc,A_Index-1,"uchar")
  166. DllCall("VirtualProtect","ptr",&MyFunc,"ptr",len,"uint",0x40,"ptr*",0)
  167. base:=DllCall("GetModuleHandle", "Str","Kernel32", "ptr")
  168. ScriptName:=ScriptName ? ScriptName : A_ScriptFullPath
  169. }
  170. Random, n, 1, 1000000
  171. pipe_name:="\\.\pipe\AHK" . A_TickCount . n
  172. cmdline="%Ahk%" "%pipe_name%" "%ScriptName%" %arg%
  173. DllCall(&MyFunc, "AStr",cmdline, "AStr",pipe_name
  174. , "ptr",base, "ptr",&str, "uint",size)
  175. return, 1
  176. }
  177.  
  178. )
  179.  
  180. if 0>0
  181. {
  182. file:=%True%
  183. IfExist, %file%
  184. Gosub, Encrypt
  185. ExitApp
  186. }
  187. Gui, +AlwaysOnTop +ToolWindow
  188. Gui, Color, DDEEFF
  189. Gui, Font, cRed s28
  190. Gui, Add, Text,, Drag the AHK script here to Encrypt`n`n
  191. Gui, Show,, AHK source code Encryptor v%Version% - By FeiYue
  192. OnMessage(0x201, "LButton_Down")
  193. LButton_Down() {
  194. SendMessage, 0xA1, 2
  195. }
  196. return
  197.  
  198. GuiClose:
  199. ExitApp
  200.  
  201. GuiDropFiles:
  202. Gui, +OwnDialogs
  203. Loop, parse, A_GuiEvent, `n
  204. {
  205. file:=A_LoopField
  206. MsgBox, 4100, Tip, Do you want to encrypt this file ?`n`n%file%
  207. IfMsgBox, Yes
  208. {
  209. Gosub, Encrypt
  210. MsgBox, 4096, Tip, Encryption is completed !
  211. }
  212. }
  213. return
  214.  
  215. Encrypt:
  216. FileRead, s, %file%
  217. s:= "`n;You can compile and set icons by using Ahk2Exe.exe`n"
  218. . "`n;If AutoHotkey.exe wants to change its name to abc.exe,"
  219. . " Please modify Ahk=%A_ScriptDir%\abc.exe`n"
  220. . "`n #NoEnv"
  221. . "`n #NoTrayIcon"
  222. . "`n #SingleInstance off"
  223. . "`n SetBatchLines, -1"
  224. . "`n if A_IsCompiled"
  225. . "`n {"
  226. . "`n Ahk=%A_ScriptDir%\AutoHotkey.exe"
  227. . "`n FileInstall, AutoHotkey.exe, %Ahk%"
  228. . "`n }"
  229. . "`n else Ahk="
  230. . "`n`ns=`n"
  231. . RegExReplace(Encode(s),".{1,60}","s.=""$0""`n")
  232. . "`n Exec(s, Ahk)"
  233. . "`n ExitApp`n"
  234. . fs
  235. f:=RegExReplace(file,"\.[^.]+$") . "-encoded.ahk"
  236. FileDelete, %f%
  237. FileAppend, %s%, %f%
  238. return
  239.  
  240. Encode(s) {
  241. static MyFunc
  242. if !MyFunc
  243. {
  244. x32:="5653BA0B00000031C083EC108B5C241C8B742420C704240"
  245. . "B000000C74424040D000000C744240811000000C744240C130"
  246. . "00000EB0889C283E2038B149469D28300000089C183E10301C"
  247. . "283C00183F86489148C75E031C085F6742A908D74260089C18"
  248. . "3E10369148C8300000001C289148C8B0C8383E901D1C931CA8"
  249. . "9148383C00139C675DB83C41031C05B5EC3909090"
  250. x64:="4883EC1841B80B00000031C0C704240B000000C74424040"
  251. . "D000000C744240811000000C744240C13000000EB0E0F1F004"
  252. . "189C04183E003468B04844569C0830000004189C14183E1034"
  253. . "101C083C00183F8644689048C75D831C085D2743266904989C"
  254. . "1448B14814183E1034669048C830000004101C04689048C458"
  255. . "D4AFF41D1C94531C8448904814883C00139C277D031C04883C"
  256. . "418C3909090909090909090"
  257. hex:=A_PtrSize=8 ? x64:x32
  258. VarSetCapacity(MyFunc, len:=StrLen(hex)//2)
  259. Loop, % len
  260. NumPut("0x" SubStr(hex,2*A_Index-1,2),MyFunc,A_Index-1,"uchar")
  261. DllCall("VirtualProtect","ptr",&MyFunc,"ptr",len,"uint",0x40,"ptr*",0)
  262. }
  263. add=
  264. (%
  265. ;-----------------------
  266. ListLines, Off
  267. My_ScriptName:=%True%
  268. Try Menu, Tray, Icon, %My_ScriptName%
  269. Gui, SingleInstance_force:Show, Hide, [%My_ScriptName%]
  270. Gui, SingleInstance_force:+HwndMy_guiid
  271. DetectHiddenWindows, On
  272. WinGet, My_list, List, [%My_ScriptName%] ahk_class AutoHotkeyGUI
  273. Loop, % My_list {
  274. IfEqual, My_guiid, % My_id:=My_list%A_Index%, Continue
  275. WinGet, My_pid, PID, ahk_id %My_id%
  276. WinClose, ahk_class AutoHotkey ahk_pid %My_pid%
  277. WinWaitClose, ahk_id %My_id%
  278. }
  279. DetectHiddenWindows, Off
  280. SetWorkingDir, % RegExReplace(My_ScriptName,"\\[^\\]*$")
  281. ;-----------------------
  282. Reload() {
  283. static My_ScriptName:=%True%
  284. Try {
  285. if My_ScriptName=
  286. return
  287. else if InStr(My_ScriptName,".exe")
  288. Run, "%My_ScriptName%"
  289. else
  290. Run, "%A_AhkPath%" "%My_ScriptName%"
  291. ExitApp
  292. }
  293. }
  294. ListLines, On
  295. ;-----------------------
  296. )
  297. s:=add "`n" s "`nExitApp`n#SingleInstance off`n"
  298. ; . togetcode(s)
  299. s:=(A_IsUnicode ? chr(0xfeff) : chr(0xEF) chr(0xBB) chr(0xBF))
  300. . RegExReplace(s,"\R","`r`n") . "`t`t`t"
  301. size:=VarSetCapacity(s,-1)//4
  302. VarSetCapacity(str, size*11*(!!A_IsUnicode+1))
  303. DllCall(&MyFunc, "ptr",&s, "int",size, "Cdecl")
  304. Loop, % size
  305. str.="u" . NumGet(s,(A_Index-1)*4,"uint")
  306. return, str
  307. }
  308.  
  309. ; If you need to read the script itself, you need it
  310. togetcode(s) {
  311. s:=StrReplace(s,"#","#0")
  312. For k,v in StrSplit("`r`n;""``")
  313. s:=StrReplace(s,v,"#" k)
  314. s:="`ngetcode(k) {`nListLines, Off`n"
  315. . "IfNotEqual,k,abc@123.com,return`ns=`n"
  316. . RegExReplace(s,".{1,60}","s.=""$0""`n")
  317. . "For k,v in StrSplit(""``r``n;""""````"")`n"
  318. . " s:=StrReplace(s,""#"" k,v)`n"
  319. . "s:=StrReplace(s,""#0"",""#"")`n"
  320. . "return, s`n}`n"
  321. return, s
  322. }
  323.  
  324. ;======== The End ========
  325.  
  326. ;
  327.  
  328. /******** The C source code ********
  329.  
  330. #include <windows.h>
  331.  
  332. typedef HANDLE (WINAPI * _GetProcAddress)(
  333. HMODULE hModule,
  334. LPCSTR lpProcName
  335. );
  336.  
  337. typedef BOOL (WINAPI * _CreateProcessA)(
  338. LPCSTR lpApplicationName,
  339. LPSTR lpCommandLine,
  340. LPSECURITY_ATTRIBUTES lpProcessAttributes,
  341. LPSECURITY_ATTRIBUTES lpThreadAttributes,
  342. BOOL bInheritHandles,
  343. DWORD dwCreationFlags,
  344. LPVOID lpEnvironment,
  345. LPCSTR lpCurrentDirectory,
  346. LPSTARTUPINFOA lpStartupInfo,
  347. LPPROCESS_INFORMATION lpProcessInformation
  348. );
  349.  
  350. typedef HGLOBAL (WINAPI * _GlobalAlloc)(
  351. UINT uFlags,
  352. SIZE_T dwBytes
  353. );
  354.  
  355. typedef HGLOBAL (WINAPI * _GlobalFree)(
  356. HGLOBAL hMem
  357. );
  358.  
  359. typedef BOOL (WINAPI * _WriteFile)(
  360. HANDLE hFile,
  361. LPCVOID lpBuffer,
  362. DWORD nNumberOfBytesToWrite,
  363. LPDWORD lpNumberOfBytesWritten,
  364. LPOVERLAPPED lpOverlapped
  365. );
  366.  
  367. typedef HANDLE (WINAPI * _CreateNamedPipeA)(
  368. LPCSTR lpName,
  369. DWORD dwOpenMode,
  370. DWORD dwPipeMode,
  371. DWORD nMaxInstances,
  372. DWORD nOutBufferSize,
  373. DWORD nInBufferSize,
  374. DWORD nDefaultTimeOut,
  375. LPSECURITY_ATTRIBUTES lpSecurityAttributes
  376. );
  377.  
  378. typedef BOOL (WINAPI * _ConnectNamedPipe)(
  379. HANDLE hNamedPipe,
  380. LPOVERLAPPED lpOverlapped
  381. );
  382.  
  383. typedef BOOL (WINAPI * _CloseHandle)(
  384. HANDLE hObject
  385. );
  386.  
  387. int WINAPI DecodeAndRun(
  388. LPCSTR cmdline, LPCSTR pipe_name,
  389. PUCHAR base, LPDWORD str, DWORD size )
  390. {
  391. DWORD index, name_num, name, win64, func=0;
  392. LPDWORD Addr_func, Addr_name, hMen;
  393. PUSHORT Addr_ord;
  394. PUCHAR tou, biao;
  395. HANDLE p1, p2;
  396. //-----------------------------
  397. tou=(PUCHAR)(base+(*(LPDWORD)(base+0x3C)));
  398. if (tou[0]!='P' || tou[1]!='E')
  399. return -1;
  400. if ((*(LPDWORD)(tou+0x60))==0||(*(LPDWORD)(tou+0x64))==0)
  401. { win64=1; index=0x88; }
  402. else
  403. { win64=0; index=0x78; }
  404. biao = (PUCHAR)(base+(*(LPDWORD)(tou+index)));
  405. name_num = *(LPDWORD)(biao+0x18);
  406. Addr_func = (LPDWORD)(base+(*(LPDWORD)(biao+0x1C)));
  407. Addr_name = (LPDWORD)(base+(*(LPDWORD)(biao+0x20)));
  408. Addr_ord = (PUSHORT)(base+(*(LPDWORD)(biao+0x24)));
  409. for (index=0; index<name_num; index++)
  410. {
  411. name=Addr_name[index]; // 'PteG'+'Acor'
  412. if ( (*(LPDWORD)(base+name)) == 0x50746547
  413. && (*(LPDWORD)(base+name+4)) == 0x41636F72 )
  414. {
  415. func=Addr_func[Addr_ord[index]];
  416. break;
  417. }
  418. }
  419. if (func==0)
  420. return -2;
  421. //-----------------------------
  422. _GetProcAddress GetProcAddress = (_GetProcAddress)(base+func);
  423.  
  424. char str1[]="WriteFile";
  425. _WriteFile WriteFile = (_WriteFile)GetProcAddress(base,str1);
  426.  
  427. char str2[]="GlobalAlloc";
  428. _GlobalAlloc GlobalAlloc = (_GlobalAlloc)GetProcAddress(base,str2);
  429.  
  430. char str3[]="GlobalFree";
  431. _GlobalFree GlobalFree = (_GlobalFree)GetProcAddress(base,str3);
  432.  
  433. char str4[]="CreateProcessA";
  434. _CreateProcessA CreateProcessA = (_CreateProcessA)GetProcAddress(base,str4);
  435.  
  436. char str5[]="CreateNamedPipeA";
  437. _CreateNamedPipeA CreateNamedPipeA = (_CreateNamedPipeA)GetProcAddress(base,str5);
  438.  
  439. char str6[]="ConnectNamedPipe";
  440. _ConnectNamedPipe ConnectNamedPipe = (_ConnectNamedPipe)GetProcAddress(base,str6);
  441.  
  442. char str7[]="CloseHandle";
  443. _CloseHandle CloseHandle = (_CloseHandle)GetProcAddress(base,str7);
  444. //-----------------------------
  445. WriteFile(0, str, 0, (LPDWORD)str1, 0);
  446. if (str1[0]!=0)
  447. return -3;
  448. hMen=(LPDWORD)GlobalAlloc(0, (size+1)*4);
  449. if (hMen==0)
  450. return -4;
  451. for (index=0; index<size; index++)
  452. hMen[index]=str[index];
  453. hMen[index]=0;
  454. //-----------------------------
  455. // Copy the contents of Decode()
  456. //-----------------------------
  457.  
  458. // My private encryption algorithm is not published here.
  459. // You can write your own encryption algorithm. Such as:
  460. for (int i=0; i<size; i++)
  461. hMen[i]=(hMen[i]^(666+i))-1;
  462.  
  463. //-----------------------------
  464. p1=CreateNamedPipeA(pipe_name, 2, 0, 255, 0, 0, 0, 0);
  465. p2=CreateNamedPipeA(pipe_name, 2, 0, 255, 0, 0, 0, 0);
  466. if ((HANDLE)-1==p1 || (HANDLE)-1==p2)
  467. {
  468. CloseHandle(p1);
  469. CloseHandle(p2);
  470. GlobalFree(hMen);
  471. return -5;
  472. }
  473. HANDLE pi[4];
  474. DWORD si[24];
  475. for (index=0; index<24; index++)
  476. si[index]=0;
  477. si[0]=win64 ? 96 : 68;
  478. if (!CreateProcessA(0, cmdline, 0,0,0, 0,0,0, si,pi))
  479. {
  480. CloseHandle(p1);
  481. CloseHandle(p2);
  482. GlobalFree(hMen);
  483. return -6;
  484. }
  485. CloseHandle(pi[0]);
  486. CloseHandle(pi[1]);
  487. ConnectNamedPipe(p1, 0);
  488. CloseHandle(p1);
  489. ConnectNamedPipe(p2, 0);
  490. WriteFile(p2, hMen, (size+1)*4, (LPDWORD)str1, 0);
  491. CloseHandle(p2);
  492. GlobalFree(hMen);
  493. return 0;
  494. }
  495.  
  496. //******** Encode() ********
  497.  
  498. int Encode(unsigned int * hMen, int size)
  499. {
  500. // My private encryption algorithm is not published here.
  501. // You can write your own encryption algorithm. Such as:
  502. for (int i=0; i<size; i++)
  503. hMen[i]=(hMen[i]+1)^(666+i);
  504. }
  505.  
  506. //******** Decode() ********
  507.  
  508. int Decode(unsigned int * hMen, int size)
  509. {
  510. // My private encryption algorithm is not published here.
  511. // You can write your own encryption algorithm. Such as:
  512. for (int i=0; i<size; i++)
  513. hMen[i]=(hMen[i]^(666+i))-1;
  514. }
  515.  
  516. */
RAW Paste Data