WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Permission issue with running a program, this program won't run autoback because of permission issues while logged on as a limited user

Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 310
Member No.: 5004
Joined: 11-May 07


This program won't run autoback because of permission issues while logged on as a limited user.

I can't understand since I run shutdown programs with no permission issues as a LU.

Thanks.

CODE
; regbk.asm Backup registry using Autoback.exe
;                
;                
             
   .386                                
   .model  flat, stdcall              
   option  casemap:none                

   include     \masm32\include\windows.inc
   include     \masm32\include\user32.inc
   include     \masm32\include\kernel32.inc
   include     \masm32\include\advapi32.inc

   include     \masm32\macros\macros.asm

   includelib  \masm32\lib\kernel32.lib
   includelib  \masm32\lib\user32.lib
   includelib  \masm32\lib\advapi32.lib

IsWinNT         PROTO
ReqNTPrivilege  PROTO :DWORD

CTEXT MACRO y:VARARG
LOCAL sym

CONST segment
 IFIDNI <y>,<>
  sym db 0
 ELSE
  sym db y,0
 ENDIF
CONST ends

EXITM <OFFSET sym>
ENDM

.CONST

.DATA

szCommandLine  BYTE   "C:\Program Files\ERUNT\autoback.exe C:\ERDNT_Backup\ [sysreg][curuser] /noconfirmdelete /days:2",0

dwMaskNT       DWORD   2
msg_NotNT      BYTE    "This is NOT an NT system.", 0
msg_NotPL      BYTE    "Privilege requested NOT granted.",13,"Unable to shutdown.", 0
AppName        BYTE    "Win NT Shutdown", 0

.data?

szComspec byte MAX_PATH dup(?)
ProcessInfo PROCESS_INFORMATION<?>
StartupInfo STARTUPINFO<?>

.code

start:

     invoke GetStartupInfo, addr StartupInfo

     invoke GetEnvironmentVariable, CTEXT('ComSpec'), addr szComspec, sizeof szComspec

invoke CreateProcess, 0, addr szCommandLine, 0, 0, FALSE, \
   NORMAL_PRIORITY_CLASS, 0, 0, addr StartupInfo, addr ProcessInfo
invoke WaitForSingleObject, ProcessInfo.hProcess, INFINITE

     invoke      IsWinNT  
     
; If is not an NT system we don't need other stuff and we can directly call ExitWindowsEx()

   .if eax == FALSE
     invoke  MessageBox, NULL, addr msg_NotNT, addr AppName, MB_OK
     invoke  ExitProcess, NULL
   .endif

; With ReqNTPrivilege call, we ask for the 'SeShutdownPrivilege,' note string
; names of possible privilege can be found in the windows.inc file.

   invoke ReqNTPrivilege, SADD("SeShutdownPrivilege")
   .if eax == FALSE
     invoke  MessageBox, NULL, addr msg_NotPL, addr AppName, MB_OK
     invoke  ExitProcess, NULL
   .endif

invoke  ExitProcess,NULL

IsWinNT proc
   
; return TRUE (not zero) in eax if we are in a Win NT system.
   
   LOCAL   osvi:OSVERSIONINFO

   mov     osvi.dwOSVersionInfoSize, sizeof osvi
   invoke  GetVersionEx, addr osvi
   .if eax == 0
     ret
   .endif
   mov     eax, osvi.dwPlatformId
   and     eax, dwMaskNT
   ret
   
IsWinNT endp

ReqNTPrivilege proc lpPrivilegeName:DWORD
   
; Return TRUE (not zero) in eax if the privilege is granted, lpPrivilegeName
; parameter points to a string with request privilege name
   
   LOCAL   hProcess:DWORD
   LOCAL   hToken:DWORD
   LOCAL   phToken:DWORD
   LOCAL   RetLen:DWORD
   LOCAL   pRetLen:DWORD
   LOCAL   tkp:TOKEN_PRIVILEGES
   LOCAL   tkp_old:TOKEN_PRIVILEGES
;
   invoke  GetCurrentProcess
   mov     hProcess, eax
   lea     eax, hToken
   mov     phToken, eax
   invoke  OpenProcessToken, hProcess, \
           TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, \
           phToken

 .if eax != FALSE
     lea     eax, tkp.Privileges[0].Luid
     invoke  LookupPrivilegeValue, NULL, \
             lpPrivilegeName, \
             eax
     lea     eax, RetLen
     mov     pRetLen, eax
     mov     tkp.PrivilegeCount, 1
     mov     tkp.Privileges[0].Attributes, SE_PRIVILEGE_ENABLED
     invoke  AdjustTokenPrivileges, hToken, \
             NULL, \
             addr tkp, \
             sizeof tkp_old, \
             addr tkp_old, \
             pRetLen
 .endif

   ret
   
ReqNTPrivilege endp
   
end     start

Sponsored Links
PMEmail Poster
Top
ragdog
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 887
Member No.: 5019
Joined: 13-May 07


Hi

Your autoback cannot run?

Try this

CODE
invoke GetStartupInfo,OFFSET sui
xor eax,eax
invoke CreateProcess,NULL,OFFSET RegCmdLine,eax,eax,\
  TRUE,eax,eax,eax,OFFSET sui,OFFSET pi




I think you must set this TRUE
PMUsers Website
Top
Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 310
Member No.: 5004
Joined: 11-May 07


QUOTE (ragdog @ Apr 15 2010, 05:35 PM)
Hi

Your autoback cannot run?

Try this

CODE

invoke GetStartupInfo,OFFSET sui
xor eax,eax
invoke CreateProcess,NULL,OFFSET RegCmdLine,eax,eax,\
  TRUE,eax,eax,eax,OFFSET sui,OFFSET pi


I think you must set this TRUE

I tried it and got this.

Warning

Error saving file

Continue with next file?

RegCreateKeyEx 5 Access is denied.
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google