Advertisement
abuehl

_cutdirs V13 MS C assembly

Sep 29th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. xdata SEGMENT
  2. $unwind$_cutdirs DD 060c01H
  3. DD 0e008320cH
  4. DD 07004c006H
  5. DD 050026003H
  6. $chain$2$_cutdirs DD 061b21H
  7. DD 0a341bH
  8. DD 0df410H
  9. DD 0cd405H
  10. DD imagerel _cutdirs
  11. DD imagerel _cutdirs+45
  12. DD imagerel $unwind$_cutdirs
  13. $chain$3$_cutdirs DD 021H
  14. DD imagerel _cutdirs
  15. DD imagerel _cutdirs+45
  16. DD imagerel $unwind$_cutdirs
  17. ; Function compile flags: /Ogtpy
  18. xdata ENDS
  19. _TEXT SEGMENT
  20. dest$ = 80
  21. seg$ = 88
  22. destlen$ = 88
  23. destsize$ = 96
  24. src$ = 104
  25. len$ = 112
  26. _cutdirs PROC
  27.  
  28. ; 502 : {
  29.  
  30. push rbp
  31. push rsi
  32. push rdi
  33. push r12
  34. push r14
  35. sub rsp, 32 ; 00000020H
  36.  
  37. ; 503 : Py_ssize_t i = 0, spaceleft = maxstorepathlen - 40 + 1;
  38.  
  39. xor edi, edi
  40. mov r12, rcx
  41.  
  42. ; 504 : char seg[8];
  43. ; 505 : int seglen = 0;
  44. ; 506 : uint32_t cmp;
  45. ; 507 :
  46. ; 508 : while (i < len && spaceleft > 0) {
  47.  
  48. mov rcx, QWORD PTR len$[rsp]
  49. mov rsi, rdx
  50. xor r8d, r8d
  51. xor edx, edx
  52. mov r14, r9
  53. lea ebp, QWORD PTR [rdi+81]
  54. test rcx, rcx
  55. jle $LN27@cutdirs
  56. mov QWORD PTR [rsp+96], r13
  57. movzx r13d, BYTE PTR seg$[rsp+2]
  58. mov QWORD PTR [rsp+104], r15
  59. movzx r15d, BYTE PTR seg$[rsp+1]
  60. mov QWORD PTR [rsp+80], rbx
  61. lea r9, OFFSET FLAT:encchar
  62. npad 1
  63. $LL15@cutdirs:
  64. test rbp, rbp
  65. jle $LN28@cutdirs
  66.  
  67. ; 509 : if (src[i] == '/' || src[i] == '\0') {
  68.  
  69. movzx eax, BYTE PTR [rdi+r14]
  70. cmp al, 47 ; 0000002fH
  71. je SHORT $LN12@cutdirs
  72. test al, al
  73. je SHORT $LN12@cutdirs
  74.  
  75. ; 531 : }
  76. ; 532 : else if (seglen == sizeof(seg)) {
  77.  
  78. cmp r8d, 8
  79. jne SHORT $LN2@cutdirs
  80.  
  81. ; 533 : i++;
  82.  
  83. inc rdi
  84.  
  85. ; 534 : }
  86. ; 535 : else {
  87.  
  88. jmp $LN1@cutdirs
  89. $LN2@cutdirs:
  90.  
  91. ; 536 : seg[seglen++] = encodechar(src[i++]);
  92.  
  93. movzx eax, al
  94. inc rdx
  95. inc r8d
  96. movzx eax, BYTE PTR [rax+r9]
  97. inc rdi
  98.  
  99. ; 537 : spaceleft--;
  100.  
  101. dec rbp
  102. mov BYTE PTR seg$[rsp+rdx-1], al
  103. mov r13b, BYTE PTR seg$[rsp+2]
  104. mov r15b, BYTE PTR seg$[rsp+1]
  105. jmp $LN1@cutdirs
  106. $LN12@cutdirs:
  107.  
  108. ; 510 : if (seglen != 0) {
  109.  
  110. test r8d, r8d
  111. je $LN11@cutdirs
  112.  
  113. ; 511 : if (seglen == 3) {
  114.  
  115. cmp r8d, 3
  116. jne SHORT $LN10@cutdirs
  117.  
  118. ; 512 : cmp = seg[0] << 16 | seg[1] << 8 | seg[2];
  119.  
  120. movsx ecx, BYTE PTR seg$[rsp]
  121. movsx eax, r15b
  122. shl ecx, 8
  123. or ecx, eax
  124. movsx eax, r13b
  125. shl ecx, 8
  126. or ecx, eax
  127.  
  128. ; 513 : if ( cmp == 0x617578 /* aux */
  129. ; 514 : || cmp == 0x636f6e /* con */
  130. ; 515 : || cmp == 0x70726e /* prn */
  131. ; 516 : || cmp == 0x6e756c /* nul */)
  132.  
  133. cmp ecx, 6387064 ; 00617578H
  134. je SHORT $LN8@cutdirs
  135. cmp ecx, 6516590 ; 00636f6eH
  136. je SHORT $LN8@cutdirs
  137. cmp ecx, 7369326 ; 0070726eH
  138. je SHORT $LN8@cutdirs
  139. cmp ecx, 7239020 ; 006e756cH
  140. jne SHORT $LN5@cutdirs
  141. $LN8@cutdirs:
  142.  
  143. ; 517 : seg[2] = '~';
  144.  
  145. mov r13b, 126 ; 0000007eH
  146. mov BYTE PTR seg$[rsp+2], r13b
  147.  
  148. ; 518 : }
  149. ; 519 : else if (seglen == 4 && seg[3] <= '9'
  150.  
  151. jmp SHORT $LN5@cutdirs
  152. $LN10@cutdirs:
  153.  
  154. ; 520 : && seg[3] >= '0') {
  155.  
  156. cmp r8d, 4
  157. jne SHORT $LN5@cutdirs
  158. movzx eax, BYTE PTR seg$[rsp+3]
  159. sub al, 48 ; 00000030H
  160. cmp al, 9
  161. ja SHORT $LN5@cutdirs
  162.  
  163. ; 521 : cmp = seg[0] << 16 | seg[1] << 8 | seg[2];
  164.  
  165. movsx ecx, BYTE PTR seg$[rsp]
  166. movsx eax, r15b
  167. shl ecx, 8
  168. or ecx, eax
  169. movsx eax, r13b
  170. shl ecx, 8
  171. or ecx, eax
  172.  
  173. ; 522 : if ( cmp == 0x636f6d /* com0..9 */
  174. ; 523 : || cmp == 0x6c7074 /* lpt0..9 */)
  175.  
  176. cmp ecx, 6516589 ; 00636f6dH
  177. je SHORT $LN4@cutdirs
  178. cmp ecx, 7106676 ; 006c7074H
  179. jne SHORT $LN5@cutdirs
  180. $LN4@cutdirs:
  181.  
  182. ; 524 : seg[3] = '~';
  183.  
  184. mov BYTE PTR seg$[rsp+3], 126 ; 0000007eH
  185. $LN5@cutdirs:
  186.  
  187. ; 525 : }
  188. ; 526 : memcopy(dest, &destlen, destsize, &seg, seglen);
  189.  
  190. movsxd rbx, r8d
  191. test r12, r12
  192. je SHORT $LN18@cutdirs
  193. lea rcx, QWORD PTR [r12+rsi]
  194. lea rdx, QWORD PTR seg$[rsp]
  195. mov r8, rbx
  196. call memcpy
  197. lea r9, OFFSET FLAT:encchar
  198. $LN18@cutdirs:
  199. mov rcx, QWORD PTR len$[rsp]
  200. add rsi, rbx
  201.  
  202. ; 527 : seglen = 0;
  203.  
  204. xor r8d, r8d
  205. xor edx, edx
  206. $LN11@cutdirs:
  207.  
  208. ; 528 : }
  209. ; 529 : charcopy(dest, &destlen, destsize, src[i++]);
  210.  
  211. test r12, r12
  212. je SHORT $LN21@cutdirs
  213. movzx eax, BYTE PTR [rdi+r14]
  214. mov BYTE PTR [r12+rsi], al
  215. $LN21@cutdirs:
  216. inc rsi
  217. inc rdi
  218.  
  219. ; 530 : spaceleft--;
  220.  
  221. dec rbp
  222. $LN1@cutdirs:
  223.  
  224. ; 504 : char seg[8];
  225. ; 505 : int seglen = 0;
  226. ; 506 : uint32_t cmp;
  227. ; 507 :
  228. ; 508 : while (i < len && spaceleft > 0) {
  229.  
  230. cmp rdi, rcx
  231. jl $LL15@cutdirs
  232. $LN28@cutdirs:
  233. mov rbx, QWORD PTR [rsp+80]
  234. mov r13, QWORD PTR [rsp+96]
  235. mov r15, QWORD PTR [rsp+104]
  236.  
  237. ; 538 : }
  238. ; 539 : }
  239. ; 540 :
  240. ; 541 : return destlen;
  241.  
  242. mov rax, rsi
  243.  
  244. ; 542 : }
  245.  
  246. add rsp, 32 ; 00000020H
  247. pop r14
  248. pop r12
  249. pop rdi
  250. pop rsi
  251. pop rbp
  252. ret 0
  253. $LN27@cutdirs:
  254.  
  255. ; 538 : }
  256. ; 539 : }
  257. ; 540 :
  258. ; 541 : return destlen;
  259.  
  260. mov rax, rsi
  261.  
  262. ; 542 : }
  263.  
  264. add rsp, 32 ; 00000020H
  265. pop r14
  266. pop r12
  267. pop rdi
  268. pop rsi
  269. pop rbp
  270. ret 0
  271. _cutdirs ENDP
  272. _TEXT ENDS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement