[API]
CallWindowProcAnsi

[DEFINE]
Private sByteA1() As Byte
Private sLongA1() As Long
Private sByteA1Pos As Long

[CODE]
#If (CallFunction_FlagA And &H100&) = &H100& Then
Private Function PrepareCode(ByVal mlngAddress As Long, ByVal IsStdCall As Boolean) As Long
#Else
Private Function PrepareCode(ByVal mlngAddress As Long) As Long
#End If
  Dim xLong1 As Long
  Dim codeStart As Long
  
  #If (CallFunction_FlagA And &H100&) = &H100& Then
    ReDim sByteA1(50& + (6& + CLng(IsStdCall)) * (UBound(sLongA1()))) '5x due no cdll
    #Else
    ReDim sByteA1(50& + 5& * (UBound(sLongA1())))  '5x due no cdll
    #End If
  codeStart = GetAlignedCodeStart(VarPtr(sByteA1(0)))
  sByteA1Pos = codeStart - VarPtr(sByteA1(0))
  For xLong1 = 0& To sByteA1Pos - 1&
    sByteA1(xLong1) = &HCC&
    Next
  AddLongToCode &H58&, &H59595959
  sByteA1(sByteA1Pos) = &H50&
  sByteA1Pos = sByteA1Pos + 1&
  
  For xLong1 = UBound(sLongA1()) - 1& To 0& Step -1&
    AddLongToCode &H68&, sLongA1(xLong1)
    Next
  AddCallToCode mlngAddress
  
  #If (CallFunction_FlagA And &H100&) = &H100& Then
    Stop
    If Not IsStdCall Then
      For xLong1 = sByteA1Pos To sByteA1Pos + UBound(sLongA1())
        sByteA1(xLong1) = &H59&
        Next
      sByteA1Pos = sByteA1Pos + UBound(sLongA1()) + 1&
      End If
    #End If
  
  sByteA1(sByteA1Pos) = &HC3&
  sByteA1Pos = sByteA1Pos + 1&
  sByteA1(sByteA1Pos) = &HCC&
  sByteA1Pos = sByteA1Pos + 1&
  
  PrepareCode = codeStart
  On Error Resume Next
  codeStart = Timer
  On Error GoTo 0
  End Function

Private Function GetAlignedCodeStart(ByVal lngAddress As Long) As Long
  GetAlignedCodeStart = lngAddress + (15& - (lngAddress - 1&) Mod 16&)
  If (15& - (lngAddress - 1&) Mod 16&) = 0& Then GetAlignedCodeStart = GetAlignedCodeStart + 16&
  End Function

Private Sub AddLongToCode(ByVal preByte As Long, ByVal xLong1 As Long)
  sByteA1(sByteA1Pos) = preByte
  Call RtlMoveMemory(sByteA1(sByteA1Pos + 1&), ByVal VarPtr(xLong1), 4&)
  sByteA1Pos = sByteA1Pos + 5&
  End Sub

Private Sub AddCallToCode(lngAddress As Long)
  AddLongToCode &HE8&, lngAddress - VarPtr(sByteA1(sByteA1Pos + 1&)) - 4&
  End Sub
