Squeeto Posted January 11, 2009 Share Posted January 11, 2009 Hi, I can't seem to get this to work past the CreateFileMapping call. Can anyone see any obvious error? expandcollapse popup#include <GUIConstants.au3> $main = GUICreate("Test1", 180, 120) $testButton = GUICtrlCreateButton("", 50, 30, 35, 25, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $testButton $fileName = @ScriptDir & "\some.exe" ExitLoop EndSelect WEnd const $PAGE_READONLY = 2 const $FILE_MAP_READ = 4 $hDll = DllOpen("kernel32.dll") If $hDll <> -1 Then $hFile = DllCall($hDll, "hwnd", "CreateFile", _ "str", $fileName, _ "dword", $GENERIC_READ, _ "dword", $FILE_SHARE_READ, _ "dword", "", _ "dword", $OPEN_EXISTING, _ "dword", $FILE_ATTRIBUTE_NORMAL, _ "hwnd", 0) If Not @error Then MsgBox(0, "Testing", $hFile[0]) $hFileMapping = DllCall($hDll, "hwnd", "CreateFileMapping", _ "hwnd", $hFile, _ "dword", "", _ "dword", $PAGE_READONLY, _ "dword", 0, _ "dword", 0, _ "str", "") If Not @error Then MsgBox(0, "Testing", $hFileMapping[0]) $pBaseAddress = DllCall($hDll, "hwnd", "MapViewOfFile", _ "hwnd", $hFileMapping, _ "dword", $FILE_MAP_READ, _ "dword", 0, _ "dword", 0, _ "uint", 0) If Not @error Then MsgBox(0, "Testing", $pBaseAddress[0]) Else MsgBox(16, "Error", "Error retreaving base address.") EndIf Else MsgBox(16, "Error", "Error creating file mapping.") EndIf Else MsgBox(16, "Error", "Error retreaving file.") EndIf DllClose($hDll) Else MsgBox(16, "Error", "Error opening Dll") EndIf Exit Thank you Link to comment Share on other sites More sharing options...
rover Posted January 11, 2009 Share Posted January 11, 2009 squeeto at a glance, you used dllcall return as a var and not an array element MsgBox(0, "Testing", $hFile[0]) $hFileMapping = DllCall($hDll, "hwnd", "CreateFileMapping", _ "hwnd", $hFile[0], _ MsgBox(0, "Testing", $hFileMapping[0]) $pBaseAddress = DllCall($hDll, "hwnd", "MapViewOfFile", _ "hwnd", $hFileMapping[0], _ Cheers I see fascists... Link to comment Share on other sites More sharing options...
Squeeto Posted January 11, 2009 Author Share Posted January 11, 2009 That fixed it. Thank you Rover. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now