Jump to content
Sign in to follow this  

_WinAPI_WriteProcessMemory Problem

Recommended Posts


I get this Windows message at random in an error dialogue box.

_WinAPI_WriteProcessMemory: Only part of a ReadProcessMemory Or

WriteProcessMemory request was completed.

It can happen 5 times in a row when I run a Rich Edit script or not happen 5 times in a row?

Here is the function that usually brings up the error, but I think the problem might be in GuiRichEdit.au3 (the function below implements clickable url links in the rich text doc).

Func WM_NOTIFY_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID
    Local $identifier, $nmhdr, $hwndFrom, $idFrom, $code
    $nmhdr = DllStructCreate($NMHDR_fmt, $lParam)
    $hwndFrom = DllStructGetData($nmhdr, 1)
    $idFrom = DllStructGetData($nmhdr, 2)
    $code = DllStructGetData($nmhdr, 3)

    if $code = $EN_LINK then
        Local $EN_LINK_struct = DllStructCreate($ENLINK_fmt, $lParam)
        ;$hwndFrom = DllStructGetData($EN_LINK_struct, 1)
        ;$idFrom = DllStructGetData($EN_LINK_struct, 2)
        ;$code = DllStructGetData($EN_LINK_struct, 3)
        Local $en_link_msg = DllStructGetData($EN_LINK_struct, 4)
        ;Local $en_link_wParam = DllStructGetData($EN_LINK_struct, 5)
        ;Local $en_link_lParam = DllStructGetData($EN_LINK_struct, 6)
        Local $cpMin = DllStructGetData($EN_LINK_struct, 7)
        Local $cpMax = DllStructGetData($EN_LINK_struct, 8)

        If BitAND($en_link_msg, $WM_LBUTTONUP) = $WM_LBUTTONUP Then
            $ClickURL = _GUICtrlRichEditGetText($h_RichEdit,$cpMin, $cpMax)

Any ideas - I don't have the skill to find the problem.

Edited by ToyleY

Share this post

Link to post
Share on other sites

It means the structure you attempted to read was larger than the available memory space so it couldn't read.


Share this post

Link to post
Share on other sites

Thanks for the reply but I still don't have a clue what to do.

Here is the function in the include file WinAPI.aus

Func _WinAPI_WriteProcessMemory($hProcess, $pBaseAddress, $pBuffer, $iSize, ByRef $iWritten, $sBuffer = "ptr")
    Local $pWritten, $tWritten, $aResult

    $tWritten = DllStructCreate("int Written")
    $pWritten = DllStructGetPtr($tWritten)
    $aResult = DllCall("Kernel32.dll", "int", "WriteProcessMemory", "int", $hProcess, "int", $pBaseAddress, $sBuffer, $pBuffer, _
            "int", $iSize, "int", $pWritten)
    _WinAPI_Check("_WinAPI_WriteProcessMemory", ($aResult[0] = 0), 0, True)
    $iWritten = DllStructGetData($tWritten, "Written")
    Return $aResult[0]
EndFunc   ;==>_WinAPI_WriteProcessMemory

I can't follow this ....................... It seems to be mixed up with memory.au3 and the problem might be, it does not wait after the DLL fiddling and mashes thing up.

The prob can't be in memory.au3 because it only call the function above - so it must the _WinAPI_WriteProcessMemory that is suspect (but I don't know what its doing so I can't fix it grrrrrrrrr!)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this