Hi,
I can't seem to get this to work past the CreateFileMapping call.
Can anyone see any obvious error?
#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