Shoutbox

[?] RtlMoveMemory: file not found - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] RtlMoveMemory: file not found (/showthread.php?tid=89858)

[?] RtlMoveMemory: file not found by SmokingCookie on 03-24-2009 at 06:46 PM

Hi folks,

I'm trying to move a string from pointer A to B. The debugger states that an exception has occurred while executing RtlMoveMemory, without any specific information. Interop.GetLastError() returns 2, which means a specified file is not found. I don't see what files have to do with moving memory data.

Can anyone help me on this one?


RE: [?] RtlMoveMemory: file not found by Mnjul on 03-24-2009 at 07:05 PM

Care to paste full code? :P (including the GetLastError part)


RE: [?] RtlMoveMemory: file not found by matty on 03-24-2009 at 07:29 PM

Javascript code:
var ptrA = Interop.Allocate(4);
var s = 'this is some text';
var ptrA_string = Interop.Allocate(2*s.length+2)
    ptrA_string.WriteString(0, s);
    ptrA.WriteDWORD(0, ptrA_string.DataPtr);
var ptrB = Interop.Allocate(4);
 
Interop.Call('kernel32', 'RtlMoveMemory', ptrB, ptrA, 4);
 
Debug.Trace(ptrB.ReadString(0));


RE: [?] RtlMoveMemory: file not found by SmokingCookie on 03-24-2009 at 07:50 PM

JScript code:
var PagePtr = lParam;
if(PagePtr === 0) {
    Internet(Script.WebURL);
    return API_SUCCESS;
}
var Size = lParam;
var oPage = Interop.Allocate(Size);
Interop.Call("Kernel32.dll","RtlMoveMemory",oPage.DataPtr,PagePtr,Size);
TraceWin32Error();


RE: [?] RtlMoveMemory: file not found by Mnjul on 03-24-2009 at 07:53 PM

Well, you're taking lParam for PagePtr's use and Size's use, I guess one should be wParam.

And matty, a 4-byte DataBloc can not hold "this is some text", which is a couple dozen bytes.


RE: [?] RtlMoveMemory: file not found by SmokingCookie on 03-24-2009 at 07:57 PM

well, that's another stupid one ^o) :S

Thanks anyway :)


RE: [?] RtlMoveMemory: file not found by matty on 03-24-2009 at 08:06 PM

quote:
Originally posted by Mnjul
And matty, a 4-byte DataBloc can not hold "this is some text", which is a couple dozen bytes.
I thought I made a booboo and changed it hence the

quote:
Originally posted by matty
This post was edited Today at 02:30 PM by matty.

RE: [?] RtlMoveMemory: file not found by TheSteve on 03-25-2009 at 12:38 AM

Is there a reason that you're using RtlMoveMemory rather than RtlCopyMemory? 

If the two buffers don't overlap (which they don't)  you should not be using RtlMoveMemory.


RE: [?] RtlMoveMemory: file not found by matty on 03-25-2009 at 10:48 AM

quote:
Originally posted by TheSteve
Is there a reason that you're using RtlMoveMemory rather than RtlCopyMemory? 

If the two buffers don't overlap (which they don't)  you should not be using RtlMoveMemory.
I didn't realize that API existed... learned something new today.
RE: [?] RtlMoveMemory: file not found by SmokingCookie on 03-25-2009 at 06:24 PM

There is.

I use this system for communication between two different scripts. RtlCopyMemory would mean lots of extra memory management to prevent leaks. Let me put it this way:

Script A sends a pointer to script B. Script B is now responsible for handling that pointer, to relieve script A (the contents of the pointer will most likely be stored in a variable). Script B then destroys the pointer (allocated by the Interop object) when it's no longer needed.

Using RtlCopyMemory would mean extra work for script A.


RE: [?] RtlMoveMemory: file not found by TheSteve on 03-26-2009 at 01:06 AM

RtlMoveMemory does not free the pointer.  You still have to manage memory yourself.

The only difference between RtlMoveMemory and RtlCopyMemory is that RtlMoveMemory is designed to work on two buffers that overlap each other. Other than that, they are the same.

If you are using DataBloc, the memory is automatically free'd when the JScript garbage collector is run. So as long as you have a reference to the object in a variable, the data will not be free'd. If you are using the Win32 API SendMessage function, the function will not return until the message has been received and handled.  All of this time, you still have a reference to the DataBloc, so the memory is still valid.