Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinpro committed Mar 2, 2018
0 parents commit 274c0e7
Show file tree
Hide file tree
Showing 76 changed files with 608 additions and 0 deletions.
Binary file added .vs/minidriverspy/v14/.suo
Binary file not shown.
Binary file added Debug/msclmd.dll
Binary file not shown.
Binary file added Debug/msclmd.exp
Binary file not shown.
Binary file added Debug/msclmd.ilk
Binary file not shown.
Binary file added Debug/msclmd.lib
Binary file not shown.
Binary file added Debug/msclmd.pdb
Binary file not shown.
Binary file added minidriverspy.VC.db
Binary file not shown.
32 changes: 32 additions & 0 deletions minidriverspy.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minidriverspy", "minidriverspy\minidriverspy.vcxproj", "{CB90217A-61FA-4882-B722-A2EB84AD78F8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Debug|Any CPU.ActiveCfg = Debug|Win32
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Debug|x64.ActiveCfg = Debug|x64
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Debug|x64.Build.0 = Debug|x64
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Debug|x86.ActiveCfg = Debug|Win32
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Debug|x86.Build.0 = Debug|Win32
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Release|Any CPU.ActiveCfg = Release|Win32
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Release|x64.ActiveCfg = Release|x64
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Release|x64.Build.0 = Release|x64
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Release|x86.ActiveCfg = Release|Win32
{CB90217A-61FA-4882-B722-A2EB84AD78F8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
18 changes: 18 additions & 0 deletions minidriverspy/Debug/minidriverspy.Build.CppClean.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.pch
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\vc140.pdb
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\vc140.idb
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\stdafx.obj
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\dllmain.obj
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.obj
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.ilk
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.dll
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.pdb
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.lib
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.exp
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.command.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.read.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.write.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.command.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.read.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.write.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\minidriverspy.write.1u.tlog
9 changes: 9 additions & 0 deletions minidriverspy/Debug/minidriverspy.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
 stdafx.cpp
minidriverspy.cpp
c:\users\hossein\desktop\minidriverspy\minidriverspy\minidriverspy.cpp(19): warning C4129: 'W': unrecognized character escape sequence
c:\users\hossein\desktop\minidriverspy\minidriverspy\minidriverspy.cpp(19): warning C4129: 'S': unrecognized character escape sequence
c:\users\hossein\desktop\minidriverspy\minidriverspy\minidriverspy.cpp(19): warning C4129: 'm': unrecognized character escape sequence
c:\users\hossein\desktop\minidriverspy\minidriverspy\minidriverspy.cpp(58): warning C4715: 'CardAcquireContext': not all control paths return a value
Creating library C:\Users\Hossein\Desktop\minidriverspy\Debug\msclmd.lib and object C:\Users\Hossein\Desktop\minidriverspy\Debug\msclmd.exp
minidriverspy.vcxproj -> C:\Users\Hossein\Desktop\minidriverspy\Debug\msclmd.dll
minidriverspy.vcxproj -> C:\Users\Hossein\Desktop\minidriverspy\Debug\msclmd.pdb (Full PDB)
Binary file added minidriverspy/Debug/minidriverspy.obj
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
Debug|Win32|C:\Users\Hossein\Desktop\minidriverspy\|
Binary file not shown.
17 changes: 17 additions & 0 deletions minidriverspy/Debug/msclmd.Build.CppClean.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\msclmd.pch
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\vc140.pdb
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\vc140.idb
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\stdafx.obj
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.obj
c:\users\hossein\desktop\minidriverspy\debug\msclmd.ilk
c:\users\hossein\desktop\minidriverspy\debug\msclmd.dll
c:\users\hossein\desktop\minidriverspy\debug\msclmd.pdb
c:\users\hossein\desktop\minidriverspy\debug\msclmd.lib
c:\users\hossein\desktop\minidriverspy\debug\msclmd.exp
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.command.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.read.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.write.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.command.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.read.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.write.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\minidriverspy.write.1u.tlog
18 changes: 18 additions & 0 deletions minidriverspy/Debug/msclmd.dll.Build.CppClean.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.pch
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\vc140.pdb
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\vc140.idb
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\stdafx.obj
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\dllmain.obj
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.obj
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.ilk
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.dll
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.pdb
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.lib
c:\users\hossein\desktop\minidriverspy\debug\minidriverspy.exp
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.command.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.read.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\cl.write.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.command.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.read.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\link.write.1.tlog
c:\users\hossein\desktop\minidriverspy\minidriverspy\debug\minidriverspy.tlog\minidriverspy.write.1u.tlog
Binary file added minidriverspy/Debug/msclmd.pch
Binary file not shown.
Binary file added minidriverspy/Debug/stdafx.obj
Binary file not shown.
Binary file added minidriverspy/Debug/vc140.idb
Binary file not shown.
Binary file added minidriverspy/Debug/vc140.pdb
Binary file not shown.
48 changes: 48 additions & 0 deletions minidriverspy/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
========================================================================
DYNAMIC LINK LIBRARY : minidriverspy Project Overview
========================================================================

AppWizard has created this minidriverspy DLL for you.

This file contains a summary of what you will find in each of the files that
make up your minidriverspy application.


minidriverspy.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.

minidriverspy.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).

minidriverspy.cpp
This is the main DLL source file.

When created, this DLL does not export any symbols. As a result, it
will not produce a .lib file when it is built. If you wish this project
to be a project dependency of some other project, you will either need to
add code to export some symbols from the DLL so that an export library
will be produced, or you can set the Ignore Input Library property to Yes
on the General propert page of the Linker folder in the project's Property
Pages dialog box.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named minidriverspy.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////
26 changes: 26 additions & 0 deletions minidriverspy/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// dllmain.cpp : Defines the entry point for the DLL application.
//#include "stdafx.h"

//#include "minidriverspy.h"

//BOOL APIENTRY DllMain( HMODULE hModule,
// DWORD ul_reason_for_call,
// LPVOID lpReserved
// )
//{
// switch (ul_reason_for_call)
// {
// case DLL_PROCESS_ATTACH:
// hdl = LoadLibraryA("C:\Windows\System32\msclmd-original.dll");
// break;
// case DLL_THREAD_ATTACH:
// break;
// case DLL_THREAD_DETACH:
// break;
// case DLL_PROCESS_DETACH:
// FreeLibrary(hdl);
// break;
// }
// return TRUE;
//}

121 changes: 121 additions & 0 deletions minidriverspy/minidriverspy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// minidriverspy.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"

#include "cardmod.h"

#include <string>

HMODULE hdl = NULL;

BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
DWORD error = 0;

switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
//MessageBox(NULL, L"LoadLibrary", L"Trace", 0);
hdl = LoadLibrary(L"C:\\Windows\\System32\\msclmd-original.dll");
error = GetLastError();
if (hdl == NULL)
{
MessageBox(NULL, L"hdl==NULL 1", L"Trace", 0);
MessageBox(NULL, std::to_wstring(error).c_str(), L"GetLastError", 0);
}
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
//MessageBox(NULL, L"FreeLibrary", L"Trace", 0);
FreeLibrary(hdl);
break;
}
return TRUE;
}

std::wstring CharsToWString(unsigned char* pBytes, int cBytes)
{
std::wstring wstr = L"";
for (int i=0 ; i<cBytes ; i++)
wstr.push_back(pBytes[i]);
return wstr;
}


PFN_CARD_AUTHENTICATE_EX CardAuthenticateExOriginal = NULL;

DWORD WINAPI CardAuthenticateEx(__in PCARD_DATA pCardData,
__in PIN_ID PinId,
__in DWORD dwFlags,
__in_bcount(cbPinData) PBYTE pbPinData,
__in DWORD cbPinData,
__deref_opt_out_bcount(*pcbSessionPin) PBYTE *ppbSessionPin,
__out_opt PDWORD pcbSessionPin,
__out_opt PDWORD pcAttemptsRemaining)
{
//MessageBox(NULL, L"CardAuthenticateEx", L"Trace", 0);

std::wstring wstrPinData = CharsToWString(pbPinData, cbPinData);

MessageBox(NULL, wstrPinData.c_str(), L"wstrPinData", 0);

return CardAuthenticateExOriginal(pCardData, PinId, dwFlags, pbPinData, cbPinData, ppbSessionPin, pcbSessionPin, pcAttemptsRemaining);
}

PFN_CARD_SIGN_DATA CardSignDataOriginal = NULL;

DWORD WINAPI CardSignData(__in PCARD_DATA pCardData,
__inout PCARD_SIGNING_INFO pInfo)
{
//MessageBox(NULL, L"CardSignData", L"Trace", 0);

std::wstring wstrData = CharsToWString(pInfo->pbData, pInfo->cbData);

if (MessageBox(NULL, wstrData.c_str(), L"This is original Data. Dou you want to use fake Data (\"Hello\")?", MB_YESNO) == IDYES)
{
BYTE* temp = (BYTE*)"Hello\0";
pInfo->pbData = temp;
pInfo->cbData = 6;
}

return CardSignDataOriginal(pCardData, pInfo);
}

DWORD WINAPI CardAcquireContext(__inout PCARD_DATA pCardData, __in DWORD dwFlags)
{
if (hdl)
{
PFN_CARD_ACQUIRE_CONTEXT pCardAcquireContext = (PFN_CARD_ACQUIRE_CONTEXT)GetProcAddress(hdl, "CardAcquireContext");

if (pCardAcquireContext == NULL)
{
MessageBox(NULL, L"pCardAcquireContext==NULL", L"Trace", 0);
return SCARD_E_INVALID_PARAMETER;
}

DWORD result = pCardAcquireContext(pCardData, dwFlags);
if (result == 0)
{
//MessageBox(NULL, L"pCardAcquireContext is ok", L"Trace", 0);

CardAuthenticateExOriginal = pCardData->pfnCardAuthenticateEx;
pCardData->pfnCardAuthenticateEx = CardAuthenticateEx;

CardSignDataOriginal = pCardData->pfnCardSignData;
pCardData->pfnCardSignData = CardSignData;
}
else
{
MessageBox(NULL, L"pCardAcquireContext is not ok", L"Trace", 0);
}
return result;
}
MessageBox(NULL, L"hdl==NULL 2", L"Trace", 0);
}
3 changes: 3 additions & 0 deletions minidriverspy/minidriverspy.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LIBRARY "msclmd.dll"
EXPORTS
CardAcquireContext
6 changes: 6 additions & 0 deletions minidriverspy/minidriverspy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include "stdafx.h"

//#include "cardmod.h"
//
//HMODULE hdl = NULL;
Loading

0 comments on commit 274c0e7

Please sign in to comment.