I am struggling with VISTA 64-bit privileges to use the OpenProcess API in my dockbar project named "Of The bay".
Note: OTB works just fine on VISTA 32-bit and XP...
i have tried to diable the UAC but this didn't solved anything.
In the code below i am not able to get the Desktop ListView ItemText nor the ItemPosition.
I am opening the process like this:
Full code to create OTB file:
Note: OTB works just fine on VISTA 32-bit and XP...
i have tried to diable the UAC but this didn't solved anything.
In the code below i am not able to get the Desktop ListView ItemText nor the ItemPosition.
I am opening the process like this:
Code:
hProgMan = FindWindow("Progman", "Program Manager") hListView = FindWindowEx(hProgMan, 0, "SHELLDLL_DefView", "") hListView = FindWindowEx(hListView, 0, "SysListView32", "FolderView") nItemCount = SendMessage(hListView, %LVM_GETITEMCOUNT, 0, 0) IF nItemCount THEN LOCAL dwProcessId, hProcess, dwSize, lpData AS DWORD CALL GetWindowThreadProcessId(hListView, dwProcessId) hProcess = OpenProcess(%PROCESS_VM_OPERATION OR %PROCESS_VM_READ OR %PROCESS_VM_WRITE, %FALSE, dwProcessId) IF hProcess THEN '// Compute the size of our reserved memory buffer dwSize = SIZEOF(POINTAPI) + SIZEOF(LVITEM) + %MAX_PATH * 2 lpData = VirtualAllocEx(hProcess, BYVAL %NULL, dwSize, %MEM_COMMIT, %PAGE_READWRITE) IF lpData THEN
Code:
'+--------------------------------------------------------------------------+ '| DoOTB | '| | '| Create a "Default.OTB" to be used as template to create a customized | '| "OfTheBay.OTB" file. | '| | '+--------------------------------------------------------------------------+ '| | '| Author Patrice TERRIER | '| copyright(c) 2008 | '| www.zapsolution.com | '| [email protected] | '| | '+--------------------------------------------------------------------------+ '| Project started on : 11-27-2008 (MM-DD-YYYY) | '| Last revised : 11-27-2008 (MM-DD-YYYY) | '+--------------------------------------------------------------------------+ #COMPILE EXE "DoOTB.exe" #INCLUDE "Win32API.inc" #INCLUDE "GDImage.inc" #INCLUDE "OfTheBay.inc" '------------------------------------------------------------------------------------------ ' LOCAL section '----------------------------------------------------------------------------------------- TYPE gSpriteArrayStruct ShellTo AS ASCIIZ * 260 IconPath AS ASCIIZ * 260 WorkDir AS ASCIIZ * 260 UseLabel AS ASCIIZ * 128 CmdLine AS ASCIIZ * 260 ShowCmd AS LONG END TYPE '''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''' SUB WriteOTB(BYVAL sMsg AS STRING) STATIC DIM szFileName AS ASCIIZ * %MAX_PATH DIM hDebug AS LONG DIM NeverBeenThere AS LONG IF hDebug AND LEN(sMsg$) = 0 THEN CALL zsFClose(hDebug) NeverBeenThere = 0 EXIT SUB END IF IF NeverBeenThere = 0 THEN NeverBeenThere = -1 szFileName = "Default.OTB" CALL zsKillFile(szFileName) CALL zsFOpen(szFileName, 2, 4, hDebug) END IF CALL zsFPut(hDebug, sMsg + $CRLF) END SUB '// Main entry point FUNCTION WINMAIN (BYVAL hInstance AS LONG, _ BYVAL hPrevInstance AS LONG, _ BYVAL lpCmdLine AS ASCIIZ PTR, _ BYVAL iCmdShow AS LONG) AS LONG DIM gS(1 TO 1) AS gSpriteArrayStruct LOCAL hProgMan, hListView AS DWORD LOCAL K, nCount, nItemCount AS LONG, sLink, sEnableShortcutTrueFalse AS STRING hProgMan = FindWindow("Progman", "Program Manager") hListView = FindWindowEx(hProgMan, 0, "SHELLDLL_DefView", "") hListView = FindWindowEx(hListView, 0, "SysListView32", "FolderView") nItemCount = SendMessage(hListView, %LVM_GETITEMCOUNT, 0, 0) IF nItemCount THEN LOCAL dwProcessId, hProcess, dwSize, lpData AS DWORD CALL GetWindowThreadProcessId(hListView, dwProcessId) hProcess = OpenProcess(%PROCESS_VM_OPERATION OR %PROCESS_VM_READ OR %PROCESS_VM_WRITE, %FALSE, dwProcessId) IF hProcess THEN '// Compute the size of our reserved memory buffer dwSize = SIZEOF(POINTAPI) + SIZEOF(LVITEM) + %MAX_PATH * 2 lpData = VirtualAllocEx(hProcess, BYVAL %NULL, dwSize, %MEM_COMMIT, %PAGE_READWRITE) IF lpData THEN LOCAL pWsh AS IWshShell pWsh = NEWCOM "WScript.Shell" LOCAL pLnk AS IWshShortcut LOCAL sDeskTopPub, sDeskTopAdm AS STRING sDeskTopAdm = zsFolderGet(%CSIDL_DESKTOP) sDeskTopPub = zsFolderGet(%CSIDL_COMMON_DESKTOPDIRECTORY) '// Setup pointers LOCAL lpPosition, lpItem, lpText AS LONG lpPosition = lpData lpItem = lpData + SIZEOF(POINTAPI) lpText = lpData + SIZEOF(POINTAPI) + SIZEOF(LVITEM) LOCAL lvi AS LVITEM LOCAL szTxt AS ASCIIZ * 128, szLnk AS ASCIIZ * (%MAX_PATH * 2) ' Allow room for unicode LOCAL DoLnk AS LONG FOR K = 0 TO nItemCount - 1 '// Init LVITEM structure and copy it to our reserved memory buffer lvi.mask = %LVIF_TEXT lvi.iItem = K lvi.iSubItem = 0 lvi.pszText = lpText lvi.cchTextMax = %MAX_PATH * 2 CALL WriteProcessMemory(hProcess, lpItem, lvi, sizeof(LVITEM), 0) '// Get text label and x,y location CALL SendMessage(hListView, %LVM_GETITEMTEXT, K, lpItem) CALL SendMessage(hListView, %LVM_GETITEMPOSITION, K, lpPosition) '// Copy from process memory to local variables szTxt = "" CALL ReadProcessMemory(hProcess, lpText, szTxt, SIZEOF(szTxt), 0) LOCAL p AS POINTAPI CALL ReadProcessMemory(hProcess, lpPosition, p, SIZEOF(POINTAPI), 0) IF LEN(szTxt) THEN szLnk = szTxt + ".lnk" '>>>>>>>>>>>>>>> msgbox szLnk '// This one is empty, meaning i can't get the ItemText not the ItemPosition IF ISFILE(sDeskTopAdm + szLnk) THEN sLink = sDeskTopAdm + szLnk ELSEIF ISFILE(sDeskTopPub + szLnk) THEN sLink = sDeskTopPub + szLnk ELSE sLink = "" END IF sTarget$ = "" IF LEN(sLink) THEN DoLnk = -1 pLnk = pWsh.CreateShortcut(UCODE$(sLink)) sTarget$ = RTRIM$(ACODE$(pLnk.TargetPath)) IF LEN(sTarget$) = 0 THEN sTarget$ = ResolveLnk((sLink)) ELSE DoLnk = 0 sTarget$ = ResolveShortcutName(szTxt) END IF IF LEN(sTarget$) THEN INCR nCount REDIM PRESERVE gS(1 TO nCount) gs(K).IconPath = "@[email protected]\48x48\????.png" IF DoLnk THEN gS(nCount).ShellTo = LCASE$(ACODE$(pLnk.TargetPath)) IF DoLnk THEN gS(nCount).WorkDir = ACODE$(pLnk.WorkingDirectory) gS(nCount).UseLabel = szTxt IF DoLnk THEN gS(nCount).ShowCmd = pLnk.WindowStyle END IF NEXT '// Freeup memory CALL VirtualFreeEx(hProcess, lpData, 0, %MEM_RELEASE) END IF '// Close process CALL CloseHandle(hProcess) LET pWsh = NOTHING END IF END IF IF nCount THEN WriteOTB "'+--------------------------------------------------------------------------+" WriteOTB "'| Of The Bay |" WriteOTB "'| |" WriteOTB "'| User shorcut definition |" WriteOTB "'| |" WriteOTB "'+--------------------------------------------------------------------------+" WriteOTB "'| |" WriteOTB "'| Author Patrice TERRIER |" WriteOTB "'| copyright(c) 2008 |" WriteOTB "'| www.zapsolution.com |" WriteOTB "'| [email protected] |" WriteOTB "'| |" WriteOTB "'+--------------------------------------------------------------------------+" WriteOTB "'Use @[email protected] to match either the OfTheBay.EXE path or the ShellTo target path" WriteOTB "'" WriteOTB "'Icon:" WriteOTB "'Use either 32x32 or larger (will be converted to 48x48)" WriteOTB "'in case of 32x32 the program adds the active icon background else not." WriteOTB "'" WriteOTB "'""ShellTo, UseLabel, IconName, WorkDir, CmdLine, EnableShortcutTrueFalse""" WriteOTB "'EnableShortcutTrueFalse = 2 '// To inform OTB that this one refers to the ""Recycle Bin""" WriteOTB "'" WriteOTB "'Replace ""@[email protected]\48x48\????.png"" with a custom PNG file." WriteOTB "'" FOR K = 1 TO nCount sEnableShortcutTrueFalse = ", 1""" IF LEN(gS(K).ShellTo) = 0 THEN gS(K).ShellTo = gS(K).UseLabel ELSE IF INSTR(gS(K).ShellTo, "ofthebay.exe") THEN sEnableShortcutTrueFalse = ", 0""" ' Don't show it IF PATHNAME$(PATH, gS(K).ShellTo) = RTRIM$(LCASE$(gS(K).WorkDir), "\") + "\" THEN gS(K).WorkDir = "@[email protected]" END IF WriteOTB """" + gS(K).ShellTo + ", " + gS(K).UseLabel + ", " + gs(K).IconPath + ", " + gS(K).WorkDir + ", " + gS(K).CmdLine + sEnableShortcutTrueFalse NEXT WriteOTB "'" WriteOTB "'End of file." WriteOTB "" END IF MsgBox """Default.OTB"" file, has been created." + $cr + $cr + _ "You must edit and save it under the name of:" + $cr + _ """OfTheBay.OTB""", , "Of The Bay" END FUNCTION
Comment