SlideShare a Scribd company logo
1 of 3
Download to read offline
Driver Development for Windows 64-bit
Author: Evgeniy Ryzhkov

Date: 24.03.2007


Abstract
Questions concerned with the release of drivers for 64-bit versions of Windows are considered in this
article. Some typical problems and the ways of their solutions are listed in the article as well as tools
which simplify the process of drivers developing.


Introduction
The output of the first version of the Windows operating system for 64-bit AMD64 processors in 2005
posed a new problem for driver developers. This problem was the opportunity to release drivers for 32-
bit and 64-bit systems. At that time many manufacturers turned out not to be ready for supporting of
drivers for two systems, that's why many devices didn't get any renewed drivers. At that time this was
excusable because 64-bit systems were a novelty and only few users could appreciate them. However,
the situation changed greatly when Windows Vista x64 was released. Now even home users want to
have a 64-bit system and the developers have to think about the release of 64-bit versions of drivers
without fail.

First of all there arises a question. "Do the 64-bit drivers for 64-bit versions of Windows have to be
developed?" And there comes a definite answer: "They do". The point is that it is impossible to use 32-
bit drivers with a 64-bit system in the kernel mode.

While developing drivers for 64-bit system one should take into consideration some peculiarities. The
neglect of them can possibly lead to vain attempts to understand why some things do not function as
they used to. MSDN covers the question of 64-bit drivers development thoroughly enough, but
sometimes the information turns out to be too uncoordinated. That's why this article gives a survey of
main problems and directions for the further study of this question.


Main Theses
While developing drivers for Win64 it is desirable to use the same source code that was used for Win32.
The differences in code should be brought to separate code sections under conditional compilation.

    •   Let's enumerate some important theses which are concerned with 64-bit drivers.
    •   The support of DMA (Direct Memory Access).The inclusion of support of 64-bit addressing in the
        driver allows to increase the productivity considerably.
    •   The support of 32-bit in-out. If a driver uses DMA procedures correctly with Windows 2000, it
        should also function normally with 64-bit systems.
    •   A driver must support both 32-bit and 64-bit versions of IOCTL commands.

It is necessary to mention the fact that Microsoft provides the developers with instructions of code
migration for new versions of Windows DDK as much as possible.
Possible Code Problems
The list of possible problems of code migration is given in [1, 2, 3]. But these problems are only named
there. And here we shall consider variants of their solutions in detail.

So, MSDN recommends us to use:

    •   New data types, secure from the point of view of Win64. These are, first of all, types of fixed
        length as well as types meant especially for pointer storage.
    •   Correct format lines in printf-like functions. As the size of pointers with 32-bit and 64-bit is
        different, so we can't use one and the same format line. The perfect solution here is total refusal
        to use such functions instead of using less dangerous analogues.
    •   When it is necessary to cut off a pointer, one should use PtrToLong and PtrToUlong functions.
        Yet, you'd better alter the code in such a way that this operation becomes unnecessary. The
        matter is that the pointer becomes incorrect after such an operation.
    •   One should use FIELD_OFFSET and TYPE_ALIGNMENT macros instead of explicit evaluation of
        the position of variable in the structure or manual alignment calculation. This is concerned with
        different types of alignment and the size of pointers.

Special attention should be paid to:

    •   Operations with signed variables and unsigned variables. The questions of variable type
        conversion often cause misunderstanding; that's why it's better to avoid them.
    •   Function call, where one of the parameters is a pointer. The potential error may be located both
        inside the function and outside of it when the result of its work is used.
    •   The use of magic constants which may change depending upon the digit capacity of the system.
        Notice, that the number -1 with a 64-bit system is not equal to 0xffffffff as it used to be with a
        32-bit one. What is this number equal to then? Naturally, it is equal to 0xffffffffffffffff, whereas
        0xffffffff equals only to 0x00000000ffffffff.
    •   Structures which contain pointers. The changes of address space occurred in 64-bit systems may
        directly affect the functioning of drivers.
    •   The conversion of pointers to some data types (int, long).


Tools
To check the efficiency of drivers it is advisable to use appropriate tools. In addition to the maximum
level of compiler diagnostics (/W4 or even /Wall) it is necessary to use other opportunities without fail.
 First of all, take a note of a free tool created by Microsoft, PREfast analyzer if you are not aware of it
yet. It's a static code analyzer; it discovers a great number of errors which can be found in common
programs besides the errors we have considered above.

Another static code analyzer, Viva64, is meant for search of the errors in C++ programs which appear
when the code migration from 32-bit systems to 64-bit ones is performed.


Conclusion
As you may see, the development of 64-bit drivers is quite easy and the tools which can facilitate this
work are available. And this means that you don't have to put off the work.
References
  1. Designing for 64-bit Windows. http://www.viva64.com/go.php?url=1.
  2. FAQ for Development on 64-bit Windows. http://www.viva64.com/go.php?url=2.
  3. Windows Driver Kit: Kernel-Mode Driver Architecture. Porting Issues Checklist.
     http://www.viva64.com/go.php?url=3.

More Related Content

Similar to Driver Development for Windows 64-bit

Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemAndrey Karpov
 
Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemPVS-Studio
 
Lesson 19. Pattern 11. Serialization and data interchange
Lesson 19. Pattern 11. Serialization and data interchangeLesson 19. Pattern 11. Serialization and data interchange
Lesson 19. Pattern 11. Serialization and data interchangePVS-Studio
 
Static code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsStatic code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsPVS-Studio
 
Viva64: working up of 64-bit applications
Viva64: working up of 64-bit applicationsViva64: working up of 64-bit applications
Viva64: working up of 64-bit applicationsPVS-Studio
 
20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platformPVS-Studio
 
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...Andrey Karpov
 
20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platformAndrey Karpov
 
64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...
64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...
64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...Andrey Karpov
 
The forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs developmentThe forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs developmentPVS-Studio
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsPVS-Studio
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsAndrey Karpov
 
Lesson 1. What 64-bit systems are
Lesson 1. What 64-bit systems areLesson 1. What 64-bit systems are
Lesson 1. What 64-bit systems arePVS-Studio
 
Developer Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit ClientsDeveloper Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit Clientspanagenda
 
Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...PVS-Studio
 
Lesson 26. Optimization of 64-bit programs
Lesson 26. Optimization of 64-bit programsLesson 26. Optimization of 64-bit programs
Lesson 26. Optimization of 64-bit programsPVS-Studio
 
Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?PVS-Studio
 

Similar to Driver Development for Windows 64-bit (20)

Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit System
 
Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit System
 
Lesson 19. Pattern 11. Serialization and data interchange
Lesson 19. Pattern 11. Serialization and data interchangeLesson 19. Pattern 11. Serialization and data interchange
Lesson 19. Pattern 11. Serialization and data interchange
 
Static code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsStatic code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applications
 
Viva64: working up of 64-bit applications
Viva64: working up of 64-bit applicationsViva64: working up of 64-bit applications
Viva64: working up of 64-bit applications
 
20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform
 
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
 
20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform
 
64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...
64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...
64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...
 
The forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs developmentThe forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs development
 
What is-32-bit-and-64-bit
What is-32-bit-and-64-bitWhat is-32-bit-and-64-bit
What is-32-bit-and-64-bit
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 
Lesson 1. What 64-bit systems are
Lesson 1. What 64-bit systems areLesson 1. What 64-bit systems are
Lesson 1. What 64-bit systems are
 
Developer Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit ClientsDeveloper Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit Clients
 
Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...
 
Lesson 26. Optimization of 64-bit programs
Lesson 26. Optimization of 64-bit programsLesson 26. Optimization of 64-bit programs
Lesson 26. Optimization of 64-bit programs
 
64 bits for developers
64 bits for developers64 bits for developers
64 bits for developers
 
Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?
 
embedded C.pptx
embedded C.pptxembedded C.pptx
embedded C.pptx
 

Recently uploaded

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Driver Development for Windows 64-bit

  • 1. Driver Development for Windows 64-bit Author: Evgeniy Ryzhkov Date: 24.03.2007 Abstract Questions concerned with the release of drivers for 64-bit versions of Windows are considered in this article. Some typical problems and the ways of their solutions are listed in the article as well as tools which simplify the process of drivers developing. Introduction The output of the first version of the Windows operating system for 64-bit AMD64 processors in 2005 posed a new problem for driver developers. This problem was the opportunity to release drivers for 32- bit and 64-bit systems. At that time many manufacturers turned out not to be ready for supporting of drivers for two systems, that's why many devices didn't get any renewed drivers. At that time this was excusable because 64-bit systems were a novelty and only few users could appreciate them. However, the situation changed greatly when Windows Vista x64 was released. Now even home users want to have a 64-bit system and the developers have to think about the release of 64-bit versions of drivers without fail. First of all there arises a question. "Do the 64-bit drivers for 64-bit versions of Windows have to be developed?" And there comes a definite answer: "They do". The point is that it is impossible to use 32- bit drivers with a 64-bit system in the kernel mode. While developing drivers for 64-bit system one should take into consideration some peculiarities. The neglect of them can possibly lead to vain attempts to understand why some things do not function as they used to. MSDN covers the question of 64-bit drivers development thoroughly enough, but sometimes the information turns out to be too uncoordinated. That's why this article gives a survey of main problems and directions for the further study of this question. Main Theses While developing drivers for Win64 it is desirable to use the same source code that was used for Win32. The differences in code should be brought to separate code sections under conditional compilation. • Let's enumerate some important theses which are concerned with 64-bit drivers. • The support of DMA (Direct Memory Access).The inclusion of support of 64-bit addressing in the driver allows to increase the productivity considerably. • The support of 32-bit in-out. If a driver uses DMA procedures correctly with Windows 2000, it should also function normally with 64-bit systems. • A driver must support both 32-bit and 64-bit versions of IOCTL commands. It is necessary to mention the fact that Microsoft provides the developers with instructions of code migration for new versions of Windows DDK as much as possible.
  • 2. Possible Code Problems The list of possible problems of code migration is given in [1, 2, 3]. But these problems are only named there. And here we shall consider variants of their solutions in detail. So, MSDN recommends us to use: • New data types, secure from the point of view of Win64. These are, first of all, types of fixed length as well as types meant especially for pointer storage. • Correct format lines in printf-like functions. As the size of pointers with 32-bit and 64-bit is different, so we can't use one and the same format line. The perfect solution here is total refusal to use such functions instead of using less dangerous analogues. • When it is necessary to cut off a pointer, one should use PtrToLong and PtrToUlong functions. Yet, you'd better alter the code in such a way that this operation becomes unnecessary. The matter is that the pointer becomes incorrect after such an operation. • One should use FIELD_OFFSET and TYPE_ALIGNMENT macros instead of explicit evaluation of the position of variable in the structure or manual alignment calculation. This is concerned with different types of alignment and the size of pointers. Special attention should be paid to: • Operations with signed variables and unsigned variables. The questions of variable type conversion often cause misunderstanding; that's why it's better to avoid them. • Function call, where one of the parameters is a pointer. The potential error may be located both inside the function and outside of it when the result of its work is used. • The use of magic constants which may change depending upon the digit capacity of the system. Notice, that the number -1 with a 64-bit system is not equal to 0xffffffff as it used to be with a 32-bit one. What is this number equal to then? Naturally, it is equal to 0xffffffffffffffff, whereas 0xffffffff equals only to 0x00000000ffffffff. • Structures which contain pointers. The changes of address space occurred in 64-bit systems may directly affect the functioning of drivers. • The conversion of pointers to some data types (int, long). Tools To check the efficiency of drivers it is advisable to use appropriate tools. In addition to the maximum level of compiler diagnostics (/W4 or even /Wall) it is necessary to use other opportunities without fail. First of all, take a note of a free tool created by Microsoft, PREfast analyzer if you are not aware of it yet. It's a static code analyzer; it discovers a great number of errors which can be found in common programs besides the errors we have considered above. Another static code analyzer, Viva64, is meant for search of the errors in C++ programs which appear when the code migration from 32-bit systems to 64-bit ones is performed. Conclusion As you may see, the development of 64-bit drivers is quite easy and the tools which can facilitate this work are available. And this means that you don't have to put off the work.
  • 3. References 1. Designing for 64-bit Windows. http://www.viva64.com/go.php?url=1. 2. FAQ for Development on 64-bit Windows. http://www.viva64.com/go.php?url=2. 3. Windows Driver Kit: Kernel-Mode Driver Architecture. Porting Issues Checklist. http://www.viva64.com/go.php?url=3.