Wednesday, May 22, 2013

Windows setup project vbs custom action return value

When I create a custom action use VB script. try rollback install.  return value from vbs custom action to installer. There is a little trick things .

we want the installer silent quit , (or pop our message)  not through exception.

I easy to find the msdn  about how to return value from custom action:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa371254(v=vs.85).aspx

Custom actions written in JScript or Visual Basic, Scripting Edition (VBScript) can call an optional function. These functions must return one of the values shown in the following table.
Return valueValueDescription
msiDoActionStatusNoAction0Action not executed.
msiDoActionStatusSuccessIDOK = 1Action completed successfully.
msiDoActionStatusUserExitIDCANCEL = 2Premature termination by user.
msiDoActionStatusFailureIDABORT = 3Unrecoverable error. Returned if there is an error during parsing or execution of the JScript or VBScript.
msiDoActionStatusSuspendIDRETRY = 4Suspended sequence to be resumed later.
msiDoActionStatusFinishedIDIGNORE = 5Skip remaining actions. Not an error.

Note that Windows Installer translates the return values from all actions when it writes the return value into the log file. For example, if the action return value appears as 1 (one) in the log file, this means that the action returned msiDoActionStatusSuccess. For more information about this translation see Logging of Action Return Values.

To return a value other than success from a script custom action, you must use a function target for the custom action. The target function is specified in the Target column of the CustomAction Table.
The following script example shows you how to return success or failure from a VBScript custom action.
Function MyVBScriptCA()

    If Session.Property("CustomErrorStatus") <> "0" Then
        'return error
        MyVBScriptCA = 3
        Exit Function
    End If

    ' return success
    MyVBScriptCA = 1
    Exit Function

End Function

If this VBScript were embedded in the Binary table of the installation package as MyCA.vbs, the CustomAction Table entry for the script would be the following:

ActionTypeSourceTarget
MyCustomAction6MyCA.vbsMyVBScriptCA



Build date: 11/30/2012

We know the most important thing is  :

To return a value other than success from a script custom action, you must use a function target for the custom action. The target function is specified in the Target column of the CustomAction Table.
The following script example shows you how to return success or failure from a VBScript custom action.

But how to set the target in customaction table ?

The vs2010 does not support  us set the function name in target table directly.

We have to open msi file (use ora edit or supperora )  ,  find custom action table.

 the problem is  Action and Source when  we open the custionaction table it is a numberstring create by vs2010. so , first we need from file table find the name.  then we put the function name in customaction table  target column .




Thursday, May 16, 2013

fth 3572 fault tolerant heap shim applied to current process

"fth 3572 fault tolerant heap shim applied to current process"
After the pragram crash, the debug show infomation.


How to disable or reset it.
http://msdn.microsoft.com/en-us/library/dd744764(VS.85).aspx
Fault Tolerant Heap


Affected Platforms
Clients - Windows 7
Feature Impact
Severity - MediumFrequency - Low
Description
The Fault Tolerant Heap (FTH) is a subsystem of Windows 7 responsible for monitoring application crashes and autonomously applying mitigations to prevent future crashes on a per application basis. For the vast majority of users, FTH will function with no need for intervention or change on their part. However, in some cases, application developers and software testers may need to override the default behavior of this system.
Solution
Viewing Fault Tolerant Heap activity
Fault Tolerant Heap logs information when the service starts, stops, or starts mitigating problems for a new application. To view this information, follow these steps:
1.Click the Start menu.
2.Right-click Computer and click Manage.
3.Click Event Viewer > Applications and Services Logs > Microsoft > Windows > Fault-Tolerant-Heap
4.View FTH Events.
The service stop and start events contain no additional data. The FTH Enabled event contains the Process ID (PID), the process image name, and the process instance start time.
Disabling Fault Tolerant Heap

Caution Serious problems may occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems may require you to reinstall the operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.To disable Fault Tolerant Heap entirely on a system, set the REG_DWORD value HKLM\Software\Microsoft\FTH\Enabled to 0.
After changing this value, restart the system. FTH will no longer activate for new applications.
Resetting the list of applications tracked by FTH
Fault Tolerant heap is self-managing and will autonomously stop applying in the case that mitigations are not effective for a given application. However, if you need to reset the list of applications for which FTH is mitigating problems (for example, if you are testing an application and need to reproduce a crash that FTH is mitigating), you can run the following command from an elevated command prompt:
Rundll32.exe fthsvc.dll,FthSysprepSpecialize
Caution Running this command will clear all FTH applications, so applications that are currently functioning properly may begin to crash again after running this command.

userful link for minifilter

http://www.osronline.com/article.cfm?article=74

That's Just the Way It Is - How NT Describes I/O Requests 

http://www.easefilter.com/info/Filter%20Driver%20FAQ.htm
What is the difference between cached I/O, user non-cached I/O, and paging I/O?


https://aonprog.wordpress.com/tag/file-mini-filter-driver/

Good technical article for minifilter.

sign a driver for test

This summary is not available. Please click here to view the post.

Show wpp tarce log in traceview

After build the driver, we could use  tracelog / traceview to log/show the trace infomation.
1: input *.ctl (Control Guid) file.  that we define WPP_CONTROL_GUIDS  in trace.h  and at the same time
   create a ctl file include 1 line :  guid CtlGuid
2: input  *.tmf files.
   using tracepdb  to create tmf file , -c option create tmc file also.
tracepdb -i D:\driveout\accessch.sys -r D:\driverout -p D:\driverout\tmf -v -c
tracepdb -i D:\WFSample\accessch\out\Win7Debug\x86\accessch.sys -r D:\WFSample\accessch\out -p D:\WFSample\accessch\out\tmf -v -c
3 using tracefmt to display etl as txt.
tracefmt D:\driveout\l.etl -i D:\driveout\accessch.sys -r D:\driveout -p D:\driveout -o D:\driveout\t.txt -v

nmake2msbuild with WPP upgrate from 2010 not working

when upgarate wdk driver project oldversion  nmake project to vs2012
first use namake2msbuild  or vs2012  File-Open-covert Sources/Dirs  to upgrate the project to vs2012 vcxproj.
when this step done,I try build the solution.
Because my old driver using WPPTracing, 
I got exception " error: (WPPCreateFile)Cannot open file .., error 5"
I read/search about "Using WPP Software Tracing in KMDF Drivers"
but it did not help me to resovle this problem.
finally, I use notepad open the vcxproj file
found :
<ClCompile Include="@(ClSourceFiles)" Exclude="@(ClCompile)">
      <WppEnabled>true</WppEnabled>
      <WppKernelMode>true</WppKernelMode>
      <WppTraceFunction>DoTraceEx(LEVEL,FLAGS,MSG,...)</WppTraceFunction>
      <WppScanConfigurationData>..</WppScanConfigurationData>
    </ClCompile>
only thing I did is  replace .. with trace.h

    <ClCompile Include="@(ClSourceFiles)" Exclude="@(ClCompile)">
      <WppEnabled>true</WppEnabled>
      <WppKernelMode>true</WppKernelMode>
      <WppTraceFunction>DoTraceEx(LEVEL,FLAGS,MSG,...)</WppTraceFunction>
      <WppScanConfigurationData>trace.h</WppScanConfigurationData>
    </ClCompile>

right now, every thing is good.
it took me almost more than 3 hours to try upgrate the nmake project to vs2012 vcxproj.

DebugView CHM does work on windows 2008 or windows 7

select the chm file.
Right click property,
Click " Unblock "

Create MiniFilter Step by Step

Create MiniFilter Step by Step.
1 : Install VS2012
2 : Install WDK 8.0
3 : Install wdfcoinstaller
4 : Debug cable link  host machine and test machine.
(Debug cable could be USB or Serial )  mine is "USB to serail cable" need install driver.
5 : Config test machine.
(
setup new windows 7 , join to same domain with host machine.
Configuring a Computer for Driver Deployment, Testing, and Debugging
http://msdn.microsoft.com/EN-US/library/hh698272(v=VS.85,d=hv.2).aspx

6.1: Using visual stiduo 2012 to deploy driver to test machine.
6.2: Sign a driver for test
7 alway run code analyze
8 run debugview on test machine
9 run verifier on test machine.