News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Application manifests etc.

Started by Magnum, January 06, 2013, 01:16:30 PM

Previous topic - Next topic

Magnum

This may be of interest.

http://msdn.microsoft.com/en-us/library/bb756929.aspx

http://www.samlogic.net/articles/manifest.htm
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

there was a related post a while back
can't find it, now   :(


ahhh - here we go...
http://masm32.com/board/index.php?topic=1030.msg9465#msg9465

Jason posted a link that makes for good reading

Donkey

Quick tip with external manifests

Be sure that when you edit an external manifest you also rebuild your executable to change the modification date stamp. Ran into a lot of problems with the activation context cache keeping the old manifest in memory and ignoring my modified one. Couldn't figure out what the problem was but rebuilding the executable fixed it, turned out the system was caching the manifest and using the cached version, changing the date stamp of the executable forces the system to flush the manifest from the cache.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

i ran into a bothersome issue - that is slightly related
that is - the batch file used to build the app deletes the old EXE
the batch goes on to build a new one
in some cases, the new EXE has the creation date/time of the original file   :icon_eek:
now - that's under XP
and - the other issue seems to be under Win 7
good thing they don't happen on the same machine   :biggrin:

Magnum


#include "\MASM32\include\Resource.h"

// Contains both a version control block and a manifest block

    //1 24 "myapp.xml"

1 24 "Admin_Only.xml"


#define APP_VERSION_INFO    1     // Define at the top your .RC file

// example version resource
APP_VERSION_INFO VERSIONINFO
    FILEVERSION 1,0         //1,1,0,0
    PRODUCTVERSION 1,0         //1,1,0,0
    FILEFLAGSMASK 0x17L
    FILEFLAGS 0x0L
    FILEOS 0x4L
    FILETYPE 0x1L
    FILESUBTYPE 0x0L
{
    BLOCK "StringFileInfo"
    {
        BLOCK "040904b0"
        {
            VALUE "CompanyName", "(c) Siege_Works 2011"
            VALUE "FileDescription", "Files to Usb Drive"
            VALUE "FileVersion", "1.0"
            VALUE "InternalName", "mint.exe"
            VALUE "LegalCopyright", "(c) QHR"
            VALUE "OriginalFilename", "mint.exe"
        }
    }
    BLOCK "VarFileInfo"
    {
        VALUE "Translation", 0x409, 1200
    }
}

Admin_Only.xml


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="6.0.0.0"
    processorArchitecture="x86"
    name="mint.EXE"
    type="win32"
/>
<description>Win32 Program</description>

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator" uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Magnum

I forget to include some information.

I can't get this to work.

I am trying to create a program that will only run as an Admin.

I have used several examples from M.S. own site for a program manifest file.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave


dedndave

Andy,
here is a resource file "template" that i use

notice 3 things:

1) The first thing in the file is #include "\masm32\include\resource.h".

2) The 1 and 24 you use for a manifest have names, also:
CREATEPROCESS_MANIFEST_RESOURCE_ID and RT_MANIFEST

3) The updated constants are placed in #ifndef/#endif blocks so that if a
future version of resource.h has them defined, no error messages will be generated.
Some of the ones I have are in the newer one, but not the older one.
The file works, either way.

;#####################################################################################

;Small Window - Resource File - DednDave, 1-2013

;#####################################################################################

#include "\masm32\include\resource.h"

#ifndef  CREATEPROCESS_MANIFEST_RESOURCE_ID
#define  CREATEPROCESS_MANIFEST_RESOURCE_ID  1
#endif

#ifndef  RT_MANIFEST
#define  RT_MANIFEST                         24
#endif

#ifndef  VS_VERSION_INFO
#define  VS_VERSION_INFO                     1
#endif

#ifndef  VOS_NT_WINDOWS32
#define  VOS_NT_WINDOWS32                    0x00040004L
#endif

#ifndef  VFT_APP
#define  VFT_APP                             0x00000001L
#endif

;*************************************************************************************

#define  IDI_ICON               501

;#####################################################################################

IDI_ICON  ICON  DISCARDABLE  "SmallWin.ico"

;#####################################################################################

; manifest file

CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "SmallWin.xml"

;#####################################################################################

; file version info

VS_VERSION_INFO VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
FILEOS          VOS_NT_WINDOWS32
FILETYPE        VFT_APP
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904E4"
    BEGIN
      VALUE "CompanyName",      "YourCompanyNameHere\000"
      VALUE "FileDescription",  "AppNameHere\000"
      VALUE "FileVersion",      "1.0\000"
      VALUE "LegalCopyright",   "\251 2013 YourNameHere\000"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x409, 0x4E4
  END
END

;#####################################################################################


CREATEPROCESS_MANIFEST_RESOURCE_ID is for application EXE's
there are other named constants for things like DLL's, etc

RT_MANIFEST is a resource data type name

Magnum

I compiled using this manifest file and your template, but I can still run the program as a limited user.

Andy


<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Gunther

Dave,

good approach! Thank you for providing your code. :t

Gunther
You have to know the facts before you can distort them.

dedndave

Andy - i think you are running XP, yes/no ?

Gunther - thanks - much of it came from MSDN - some came from Hutch   :P

dedndave

the UAC stuff you are trying to do in manifest didn't come about before Vista
but, i think there is a way to do it under XP by using the startupinfo

dedndave

of course, you could let the program start up, then use...
http://msdn.microsoft.com/en-us/library/aa376389%28VS.85%29.aspx

with the manifest, the user will be required to provide admin authority for vista or above
the UAC section of the manifest will be ignored by XP
manifests are ignored altogether under win2000 and earlier

for XP and maybe win2000, you can create a shortcut to the exe that requests authentication
then use the above API to verify it before allowing the program to continue
you could also do it by checking the HKEY_USERS\S-1-5-19 key