1. Куча / Говнокод #22755

    −13

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    $aCall = DllCall("kernel32.dll", "ptr", "VirtualAlloc", _
                "ptr", 0, _
                "dword", 82, _
                "dword", 4096, _ ; MEM_COMMIT
                "dword", 64) ; PAGE_EXECUTE_READWRITE
    
        If @error Or Not $aCall[0] Then
            Return SetError(6, 0, 0)
        EndIf
    
        Local $pRemoteCode = $aCall[0]
    
        ; Make structure in reserved space
        Local $CodeBuffer = DllStructCreate("byte[82]", $pRemoteCode)
    
        ; Allocate global memory with PAGE_READWRITE. This can be done with ByRef-ing too.
        $aCall = DllCall("kernel32.dll", "ptr", "VirtualAlloc", _
                "ptr", 0, _
                "dword", 36, _
                "dword", 4096, _ ; MEM_COMMIT
                "dword", 4) ; PAGE_READWRITE
    
        If @error Or Not $aCall[0] Then
            Return SetError(7, 0, 0)
        EndIf
    
        Local $pStrings = $aCall[0]
    
        ; Arrange strings in reserved space
        Local $tSpace = DllStructCreate("wchar Format[9];wchar Result[9]", $pStrings)
        DllStructSetData($tSpace, "Format", "hh:mm:ss")
    
        ; Write assembly on the fly
        DllStructSetData($CodeBuffer, 1, _
                "0x" & _
                "68" & SwapEndian(9) & _                                           ; push output size
                "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _          ; push pointer to output container
                "68" & SwapEndian(DllStructGetPtr($tSpace, "Format")) & _          ; push pointer to format string
                "68" & SwapEndian(0) & _                                           ; push NULL
                "68" & SwapEndian(4) & _                                           ; push TIME_FORCE24HOURFORMAT
                "68" & SwapEndian(0) & _                                           ; push Locale
                "B8" & SwapEndian($pGetTimeFormatW) & _                            ; mov eax, [$pGetTimeFormatW]
                "FFD0" & _                                                         ; call eax
                "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _          ; push pointer to the result
                "68" & SwapEndian(0) & _                                           ; push wParam
                "68" & SwapEndian(12) & _                                          ; push WM_SETTEXT
                "68" & SwapEndian(GUICtrlGetHandle($hControl)) & _                 ; push HANDLE
                "B8" & SwapEndian($pSendMessageW) & _                              ; mov eax, [$pSendMessageW]
                "FFD0" & _                                                         ; call eax
                "68" & SwapEndian(491) & _                                         ; push Milliseconds
                "B8" & SwapEndian($pSleep) & _                                     ; mov eax, [$pSleep]
                "FFD0" & _                                                         ; call eax
                "E9" & SwapEndian(-81) & _                                         ; jump back 81 bytes (start address)
                "C3" _                                                             ; Ret
                )
    
        ; Create new thread to execute code in
        $aCall = DllCall("kernel32.dll", "ptr", "CreateThread", _
                "ptr", 0, _
                "dword", 0, _
                "ptr", $pRemoteCode, _
                "ptr", 0, _
                "dword", 0, _
                "dword*", 0)
    
        If @error Or Not $aCall[0] Then
            Return SetError(8, 0, 0)
        EndIf
    
        Local $hThread = $aCall[0]
    
        ; Return thread handle
        Return $hThread
    
    EndFunc   ;==>_ClockThisInAnotherThread
    
    
    Func SwapEndian($iValue)
        Return Hex(BinaryMid($iValue, 1, 4))
    EndFunc   ;==>SwapEndian

    Попытка вызвать CreateThread в однопоточном скриптовом языке.
    Код функции написан заранее, в виде опкодов. Гениально.

    Запостил: fajes_rown, 07 Апреля 2017

    Комментарии (65) RSS

    Добавить комментарий