Das ist jetzt aus meiner persönlichen Funktionssammlung rauskopiert, aber wenn man das alles in die UDF einfügt, sollte es auch klappen:
; In den Deklarationsbereich:
global SAMP_INFO_PTR := 0x21A0F8
global SAMP_MAX_TEXTLABELS := 1024
global SAMP_POOLS := 0x3CD
global SAMP_POOL_TEXTLABEL := 0xC
; TextLabel-Funktionen
updateTextLabel(textLabelID, text) {
return textLabelID < 0 || textLabelID > 2047 || !checkHandles() ? false : __WRITESTRING(hGTA, dwSAMP, [SAMP_INFO_PTR, SAMP_POOLS, SAMP_POOL_TEXTLABEL, textLabelID * 0x1D, 0x0], text)
}
createTextLabel(text, color, xPos, yPos, zPos, drawDistance := 50.0, testLOS := 0, playerID := 0xFFFF, vehicleID := 0xFFFF) {
if (!checkHandles())
return -1
dwAddress := __DWORD(hGTA, dwSAMP, [SAMP_INFO_PTR, SAMP_POOLS, SAMP_POOL_TEXTLABEL])
if (!dwAddress)
return -1
Loop, 2048 {
textLabelID := A_Index - 1
if (!__DWORD(hGTA, dwAddress, [0xE800 + textLabelID * 4])) {
return __CALL(hGTA, dwSAMP + 0x11C0, [["i", dwAddress], ["i", textLabelID], ["s", text], ["i", color], ["f", xPos], ["f", yPos], ["f", zPos]
, ["f", drawDistance], ["i", testLOS], ["i", playerID], ["i", vehicleID]], false, true) ? textLabelID : -1
}
}
return -1
}
deleteTextLabel(ByRef textLabelID) {
if (textLabelID < 0 || !checkHandles())
return false
if (__CALL(hGTA, dwSAMP + 0x12D0, [["i", __DWORD(hGTA, dwSAMP, [SAMP_INFO_PTR, SAMP_POOLS, SAMP_POOL_TEXTLABEL])], ["i", textLabelID]], false, true)) {
textLabelID := -1
return true
}
return false
}
; Memory-Funktionen
__DWORD(hProcess, dwAddress, offsets) {
if (!hProcess || !dwAddress)
return ""
VarSetCapacity(dwRead, 4)
for i, o in offsets {
dwRet := DllCall("ReadProcessMemory", "UInt", hProcess, "UInt", dwAddress + o, "Str", dwRead, "UInt", 4, "UInt*", 0)
if (!dwRet)
return ""
dwAddress := NumGet(dwRead, 0, "UInt")
}
return dwAddress
}
__READMEM(hProcess, dwAddress, oOffsets, sDatatype = "Int") {
if (!hProcess || !dwAddress)
return ""
VarSetCapacity(dwRead, 4)
for i, o in oOffsets {
dwRet := DllCall("ReadProcessMemory", "UInt", hProcess, "UInt", dwAddress + o, "Str", dwRead, "UInt", 4, "UInt*", 0)
if (!dwRet)
return ""
if (i == oOffsets.MaxIndex())
return NumGet(dwRead, 0, sDatatype)
dwAddress := NumGet(dwRead, 0, "UInt")
}
}
__WRITESTRING(hProcess, dwAddress, oOffsets, wString) {
if (!hProcess || !dwAddress)
return false
if A_IsUnicode
wString := __unicodeToAnsi(wString)
requiredSize := StrPut(wString)
VarSetCapacity(buffer, requiredSize)
for i, o in oOffsets {
if (i == oOffsets.MaxIndex()) {
StrPut(wString, &buffer, StrLen(wString) + 1)
return DllCall("WriteProcessMemory", "UInt", hProcess, "UInt", dwAddress + o, "Str", buffer, "UInt", requiredSize, "UInt", 0, "UInt")
}
dwRet := DllCall("ReadProcessMemory", "UInt", hProcess, "UInt", dwAddress + o, "Str", buffer, "UInt", 4, "UInt*", 0)
if (!dwRet)
return false
dwAddress := NumGet(buffer, 0, "UInt")
}
}
__WRITEMEM(hProcess, dwAddress, oOffsets, value, sDatatype = "Int") {
dwLen := datatypes[sDatatype]
if (dwLen < 1 || !hProcess || !dwAddress)
return false
VarSetCapacity(dwRead, 4)
for i, o in oOffsets {
if (i == oOffsets.MaxIndex()) {
NumPut(value, dwRead, 0, sDatatype)
return DllCall("WriteProcessMemory", "UInt", hProcess, "UInt", dwAddress + o, "UInt", &dwRead, "UInt", dwLen, "UInt", 0)
}
dwRet := DllCall("ReadProcessMemory", "UInt", hProcess, "UInt", dwAddress + o, "Str", dwRead, "UInt", 4, "UInt*", 0)
if (!dwRet)
return false
dwAddress := NumGet(dwRead, 0, "UInt")
}
}
__WRITERAW(hProcess, dwAddress, pBuffer, dwLen) {
return (!hProcess || !dwAddress || !pBuffer || dwLen < 1) ? false : DllCall("WriteProcessMemory", "UInt", hProcess, "UInt", dwAddress, "UInt", pBuffer, "UInt", dwLen, "UInt", 0, "UInt")
}
__CALL(hProcess, dwFunc, aParams, bCleanupStack = true, bThisCall = false, bReturn = false, sDatatype = "Char") {
if (!hProcess || !dwFunc)
return ""
dataOffset := 0
i := aParams.MaxIndex()
bytesUsed := 0
bytesMax := 5120
dwLen := i * 5 + bCleanupStack * 3 + bReturn * 5 + 6
VarSetCapacity(injectData, dwLen, 0)
while (i > 0) {
if (aParams[i][1] == "i" || aParams[i][1] == "p" || aParams[i][1] == "f")
value := aParams[i][2]
else if (aParams[i][1] == "s") {
if (bytesMax - bytesUsed < StrLen(aParams[i][2]))
return ""
value := pMemory + bytesUsed
__WRITESTRING(hProcess, value, [0x0], aParams[i][2])
bytesUsed += StrLen(aParams[i][2]) + 1
if (ErrorLevel)
return ""
}
else
return ""
NumPut((bThisCall && i == 1 ? 0xB9 : 0x68), injectData, dataOffset, "UChar")
NumPut(value, injectData, ++dataOffset, aParams[i][1] == "f" ? "Float" : "Int")
dataOffset += 4
i--
}
offset := dwFunc - (pInjectFunc + dataOffset + 5)
NumPut(0xE8, injectData, dataOffset, "UChar")
NumPut(offset, injectData, ++dataOffset, "Int")
dataOffset += 4
if (bReturn) {
NumPut(sDatatype = "Char" ? 0xA2 : 0xA3, injectData, dataOffset, "UChar")
NumPut(pMemory, injectData, ++dataOffset, "UInt")
dataOffset += 4
}
if (bCleanupStack) {
NumPut(0xC483, injectData, dataOffset, "UShort")
dataOffset += 2
NumPut((aParams.MaxIndex() - bThisCall) * 4, injectData, dataOffset, "UChar")
dataOffset++
}
NumPut(0xC3, injectData, dataOffset, "UChar")
__WRITERAW(hGTA, pInjectFunc, &injectData, dwLen)
if (ErrorLevel)
return ""
hThread := createRemoteThread(hGTA, 0, 0, pInjectFunc, 0, 0, 0)
if (ErrorLevel)
return ""
waitForSingleObject(hThread, 0xFFFFFFFF)
closeProcess(hThread)
if (bReturn)
return __READMEM(hGTA, pMemory, [0x0], sDatatype)
return true
}
Alles anzeigen