- This topic has 142 replies, 8 voices, and was last updated 10 years ago by Admin.
-
AuthorPosts
-
July 22, 2013 at 6:13 am #186062ChikeMember
As long it’s after VirtualFreeEx
July 22, 2013 at 6:34 am #186061ChikeMember@ManicMike wrote:
I forgot to add another ad lib that might explain the 20 digit number. I edited this part of the if statement
if VirtualFreeEx(..) = 0 then
result = GetLastError()
endifto
if result = 0 then
result = GetLastError()
endifthat seemed logical but suddenly is making me wonder if that is why it is acting weirder than you expected
And yes directly following the VirtualFreeEx statement right before the closeHandle
No that does not change anything
If you break before the call to GetLastError and step over it do you see reult change? (value in red)July 22, 2013 at 6:43 am #186060cyberpunkMemberThe break is on the VirtualFreeEx line so it is before GetLastError, I do see the values change from 0 to this 20 digit number, I can go back even further and get some 1’s before the 0, but the Close handle returns a 1
July 22, 2013 at 6:48 am #186059cyberpunkMemberChike, this process has taught me a great deal. I appreciate the help. If it is late where you are it can keep til later. but i am going to be up myself
July 22, 2013 at 7:02 am #186058ChikeMemberTry this maybe
Imports System.Runtime.InteropServices
...
result = Marshal.GetLastWin32Error()July 22, 2013 at 11:21 am #186057cyberpunkMemberThat returns value 87. Cool, I will have to learn what the difference is between these two methods. Does 87 tell you anything more about what the issue is? I see no information on what the code might mean in the documentation for VirtualFreeEx
July 22, 2013 at 11:44 am #186056DepartureMemberHmm lets see…
you get an error on this? with error code 87?
result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)MSDN says this..
ERROR_INVALID_PARAMETER
87 (0x57)
The parameter is incorrect.You have declared the function like this…
Declare Function VirtualFreeEx Lib “kernel32” (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal dwFreeType As Integer) As Integer
You created variables like this…
Dim pHandle As Integer
Dim pStrBufferMemory As Integer
Dim pMyItemMemory As IntegerMSDN says this about VirtualFreeEx…
Parameters
hProcess [in]
A handle to a process. The function frees memory within the virtual address space of the process.
The handle must have the PROCESS_VM_OPERATION access right. For more information, see Process Security and Access Rights.
lpAddress [in]
A pointer to the starting address of the region of memory to be freed.
If the dwFreeType parameter is MEM_RELEASE, lpAddress must be the base address returned by the VirtualAllocEx function when the region is reserved.
dwSize [in]
The size of the region of memory to free, in bytes.hmm Parameter lpAddress [in] requires a pointer, pStrBufferMemory As Integer and pMyItemMemory As Integer seems you are passing an integer value and not a pointer?
I could be completely wrong here as I haven’t personally used this code or looked through it properly.
July 22, 2013 at 11:52 am #186055cyberpunkMemberLink didn’t work, trying to locate the URL the old fashioned way through google now, clearly you would not have posted a link unless it was relevant, Damn MSDN too, I was on MSDN for the documentation, I didn’t see anything about this, I found one obscure reference to this function returning 87 refers to non aligned pages or something, but that was the only thing I came up with, still googling
July 22, 2013 at 12:24 pm #186054cyberpunkMemberI see why you say that…You laid that out very well. But when I hover over the pMyItemMemory is does say it is being declared as a IntPtr (after I edited it to do so) though and has a ten digit value set for it during codewalks, i am assuming that is the lpAddress
It returns 87 whether it is declared as Integer or IntPtr
July 22, 2013 at 12:50 pm #186053DepartureMemberJuly 22, 2013 at 1:17 pm #186052cyberpunkMember@Departure wrote:
i added the .aspx too and it still came out as Page not found error, but I suspect your post gave me the particulars. I am googling now to see what I can found out, Just all the other functions autopilot is using in his syslistview module seem to work the same way. Well, it is not like we use his functions once a second either. so they might have the same issue. But IntPtr made no change.
I did a search for ms681382 and NOW I see what you where linking me too. a list of Error Codes! Awesome! lol Bookmarked for future quick access. no doubt I will use this a lot.
July 22, 2013 at 2:31 pm #186051ChikeMember@Departure wrote:
hmm Parameter lpAddress [in] requires a pointer, pStrBufferMemory As Integer and pMyItemMemory As Integer seems you are passing an integer value and not a pointer?
I could be completely wrong here as I haven’t personally used this code or looked through it properly.
The ponters should be declared IntPtr but this does not make a difference in 32bit winfows, and it didn’t bother the write/read memory functions, so why whould it be different?
If VirtualAllocEx returned a value greater than 32bit it would raise an exception in runtimewhen trying to assign it to an integer.
So what other parameters are there that can turn to be a bad parameter?
@ManicMike wrote:
I did a search for ms681382 and NOW I see what you where linking me too. a list of Error Codes! Awesome! lol Bookmarked for future quick access. no doubt I will use this a lot.
Yeah I did that too back in the days, now my bokmarks list is so long I just coogle “windows error codes”
So now that you have all the information you need, chop chop.July 22, 2013 at 2:57 pm #186050cyberpunkMemberlol @ chop chop
I get the issue is that it is not releasing the memory, but from what I can tell I am giving it the proper parameters. clearly I am not or am missing something. The Error message indicates that it doesn’t like the parameter I am giving it, but lol it is all I got to give it. I will try to think outside the box. I will study up on the functions involved and see what pops up, I have no issue with you guys holding back on me.
Just to verify what you said about the IntPtr, it did not alter the symptoms one bit.
I will post back if I need another hint. I can see there more than a few functions documentation that I need to read on this.
I do appreciate the lesson in how to properly troubleshoot code issues. I feel silly now looking back at how I didn’t see the value of setting a breakpoint, just didn’t occur to me to hover over variables. That really does make troubleshooting code very logical.
July 22, 2013 at 3:18 pm #186049ChikeMember@ManicMike wrote:
I get the issue is that it is not releasing the memory, but from what I can tell I am giving it the proper parameters. clearly I am not or am missing something.
Those stupid programmers at microsoft i’m telling ya.
“from what I can tell”…
Lets for a moment assume them microsoft programmers are not THAT stupid, and there is/are bad parameter(s).
We (I) already excluded the option it’s the pointers, what else we got?
1. Process handle, but closehandle as well as VirtualAllocEx don’t fail.
2. Size, but you pass 0 which is in comliance with the documentation and the type of free you want to make.
3. Free type, but that looks to be what it should according to documentation, or is it? (damn big hint)Not everything is what it “looks” to be, you have to know how to look.
July 22, 2013 at 3:43 pm #186048cyberpunkMemberDamn good hint Chike
Now getting a return of 1
Making changes to all subs and going to test it out. and while testing I will be googling why some Const have an S at the end. I took a guess and added it though the example I saw didn’t have it. Seemed logical to add the S since the MEM_COMMIT had it. I have learned a great deal. Thanks guys.
Final Update to this issue:
Issue Resolved thanks to Chike’s smacking me over the head with a clue club.Good call Chike.
-
AuthorPosts
Related
- You must be logged in to reply to this topic.