This will create a desktop.... then it will make a working Dialog... right now im having one problem that i will have to do a system wide hook i think unless you guys know another way to tell a program to use a diff desktop...
right now all i know is that i have to tell the problem to use my desktop with this api SetThreadDesktop
EDIT: I Removed the CreateWrokStation is not needed
right now all i know is that i have to tell the problem to use my desktop with this api SetThreadDesktop
EDIT: I Removed the CreateWrokStation is not needed
; #########################################################################
.386
.model flat, stdcall
option casemap :none ; case sensitive
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comdlg32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comdlg32.lib
; #########################################################################
;=============
; Local macros
;=============
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
m2m MACRO M1, M2
push M2
pop M1
ENDM
return MACRO arg
mov eax, arg
ret
ENDM
;=================
; Local prototypes
;=================
EnumWindowsProc proto :DWORD,:DWORD
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY PROTO :DWORD,:DWORD
ListBox PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
EditBox PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ButtonBox PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ListBoxProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
ReadPffFileInside PROTO :DWORD
Extract PROTO :DWORD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.const
.data
DesktopName db "Desktop2",0
DesktopName1 db "Desktop1",0
szND1TXT db "Input Desktop Not Found",0
szND1CAP db "Error 1",0
szND2TXT db "Error Creating New WorkStation",0
szND2CAP db "Error 2",0
szND3TXT db "Error Setting Access To New WorkStation",0
szND3CAP db "Error 3",0
szND4TXT db "Error Creating New Desktop",0
szND4CAP db "Error 4",0
szND5TXT db "Error Switching To New Desktop",0
szND5CAP db "Error 5",0
szND6TXT db "Error SetThreadDesktop",0
szND6CAP db "Error 6",0
Run_Buffer db "progman.exe",0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
szDisplayName db "Testing",00
.data?
Blank dd ?
Blank1 dd ?
Blank2 dd ?
Sec SECURITY_ATTRIBUTES <>
Sec2 SECURITY_ATTRIBUTES <>
hDesktop dd ?
hNDeskTop dd ?
OldDesk dd ?
pvInfo USEROBJECTFLAGS <>
pvSize dd ?
ProcessInfo PROCESS_INFORMATION <>
StartupInfo STARTUPINFO <>
lParam2 dd ?
lpfn dd ?
;lParam dd ?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CommandLine dd ?
hWnd dd ?
hInstance dd ?
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
invoke OpenInputDesktop,DF_ALLOWOTHERACCOUNTHOOK,TRUE,DESKTOP_CREATEMENU or DESKTOP_CREATEWINDOW\
or DESKTOP_ENUMERATE or DESKTOP_HOOKCONTROL or DESKTOP_JOURNALPLAYBACK\
or DESKTOP_JOURNALRECORD or DESKTOP_READOBJECTS or DESKTOP_SWITCHDESKTOP\
or DESKTOP_WRITEOBJECTS
mov OldDesk,eax
cmp eax,NULL
je NoDesk1
mov Sec2.nLength,0Ch
mov Sec2.lpSecurityDescriptor,NULL
mov Sec2.bInheritHandle,TRUE
invoke CreateDesktop,offset DesktopName1,Blank1,Blank2,DF_ALLOWOTHERACCOUNTHOOK,DESKTOP_CREATEMENU\
or DESKTOP_CREATEWINDOW or DESKTOP_ENUMERATE or DESKTOP_HOOKCONTROL\
or DESKTOP_JOURNALPLAYBACK or DESKTOP_JOURNALRECORD or DESKTOP_READOBJECTS\
or DESKTOP_SWITCHDESKTOP or DESKTOP_WRITEOBJECTS,offset Sec2
mov hNDeskTop,eax
cmp eax,NULL
je NoDesk4
invoke SetThreadDesktop,hNDeskTop
cmp eax,NULL
je NoDesk6
invoke SwitchDesktop,hNDeskTop
cmp eax,NULL
je NoDesk5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke CloseDesktop,hNDeskTop
invoke ExitProcess,eax
; #########################################################################
WinMain proc hInst :DWORD,
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD
;====================
; Put LOCALs on stack
;====================
LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD
;==================================================
; Fill WNDCLASSEX structure with required variables
;==================================================
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInst ;<< NOTE: macro not mnemonic
mov wc.hbrBackground, COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName
invoke LoadIcon,hInst,500 ; icon ID
mov wc.hIcon, eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
mov wc.hIconSm, 0
invoke RegisterClassEx, ADDR wc
;================================
; Centre window at following size
;================================
mov Wwd, 250
mov Wht, 680
mov Wtx, 0
mov Wty, 0
szText szClassName,"Template_Class"
invoke CreateWindowEx,WS_EX_CONTROLPARENT or WS_EX_CLIENTEDGE,
ADDR szClassName,
ADDR szDisplayName,
WS_SYSMENU or WS_MINIMIZEBOX or WS_CAPTION,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInst,NULL
mov hWnd,eax
invoke LoadMenu,hInst,600 ; menu ID
invoke SetMenu,hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
;===================================
; Loop until PostQuitMessage is sent
;===================================
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:
return msg.wParam
WinMain endp
; #########################################################################
WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD
.if uMsg == WM_COMMAND
;======== menu commands ========
.if wParam == 1000
.elseif wParam == 1001
invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
.elseif wParam == 3000
.elseif wParam == 3001
.elseif wParam == 1900
.elseif wParam == 503
.elseif wParam == 2000
.endif
;====== end menu commands ======
.elseif uMsg == WM_CREATE
.elseif uMsg == WM_CLOSE
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
WndProc endp
NoDesk1:
invoke MessageBoxA,NULL,offset szND1TXT,offset szND1CAP,MB_OK
jmp Exit
NoDesk2:
invoke MessageBoxA,NULL,offset szND2TXT,offset szND2CAP,MB_OK
jmp Exit
NoDesk3:
;int 3
invoke MessageBoxA,NULL,offset szND3TXT,offset szND3CAP,MB_OK
jmp Exit
NoDesk4:
invoke MessageBoxA,NULL,offset szND4TXT,offset szND4CAP,MB_OK
jmp Exit
NoDesk5:
invoke MessageBoxA,NULL,offset szND5TXT,offset szND5CAP,MB_OK
jmp Exit
NoDesk6:
invoke MessageBoxA,NULL,offset szND6TXT,offset szND6CAP,MB_OK
Exit:
invoke CloseDesktop,hNDeskTop
invoke ExitProcess,NULL
end start
I found out why Creating a Window Station of my own does not work the way i wanted... there was no need for it anyway but i just wanted to see how much i could do...
The interactive window station, Winsta0, is the only window station that can display a user interface or receive user input. It is assigned to the logon session of the interactive user, and contains the keyboard, mouse, and display device. All other window stations are noninteractive, which means they cannot display a user interface or receive user input. Running services under a different account prevents them from accessing the interactive window station. For more information, see
The interactive window station, Winsta0, is the only window station that can display a user interface or receive user input. It is assigned to the logon session of the interactive user, and contains the keyboard, mouse, and display device. All other window stations are noninteractive, which means they cannot display a user interface or receive user input. Running services under a different account prevents them from accessing the interactive window station. For more information, see