[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build after modifing winscard.cpp on windows 10 #33

Open
ShiZNizZLe opened this issue Mar 8, 2021 · 12 comments
Open

Build after modifing winscard.cpp on windows 10 #33

ShiZNizZLe opened this issue Mar 8, 2021 · 12 comments

Comments

@ShiZNizZLe
Copy link

After using the modified Winscard.dll the program doesn't see the smartcard reader, how can that be?
We only modified this part:

Modified:
afbeelding

Original:
afbeelding

Here are the generated logs with both the vanilla and the modded version.
We didn't modify any functionality so it seems weird that it can't find a reader.
Is there perhaps another difference between our own build and the Winscard_32b_v2.1.2 Winscard.dll?
MSTSC_VANILLA_winscard_rules_log.txt_Mon-Mar--8-08_58_24-2021.txt
MSTSC_VANILLA_winscard_log.txt_Mon-Mar--8-08_58_24-2021.txt
MSTSC_MODDED_winscard_rules_log.txt_Mon-Mar--8-08_59_59-2021.txt
MSTSC_MODDED_winscard_log.txt_Mon-Mar--8-08_59_59-2021.txt

@ShiZNizZLe
Copy link
Author
ShiZNizZLe commented Mar 8, 2021

just build it with the devel branch. I built the project in vs2019 with win32 and nothing of the files modified.
When i remove both the original32 and winscard.dll, the test program works:

MSTSC_winscard_rules_log.txt_Fri-Feb-26-12_27_55-2021.txt

When i have both present i get this weird output:

winscard_rules_log.txt_Mon-Mar--8-13_42_55-2021.txt

Do i have to do something special when i build? Because the premade 32bit winscard.dll (v2.1.2) is working properly with the program. If i can get the devel build working properly, i can do my modifications

@Arcidev
Copy link
Collaborator
Arcidev commented Mar 8, 2021

Are you sure it does not find it? The problem might be just the log not showing anything (because of string_format on the outside) as the _CONV method says if the string should be read as char/widechar based on UNICODE define.

In devel there were some changes to this unicode/ascii encoding and the log is mostlikely just showing more than the master build is (warnings and some additional logs were added with 63233a1)

@ShiZNizZLe
Copy link
Author

The log of the self built version even shows that there isn't any reader present and continues to fail everything afterwards.
While the premade version log shows everything like it should (and the test program works).

So i imagine that the pre made winscard.dll is built in someway that mine isn't?

@ShiZNizZLe
Copy link
Author

and no the test program doesn't find it. Only when i use the pre compiled dll or don't use the tool at all.

@Arcidev
Copy link
Collaborator
Arcidev commented Mar 10, 2021

I can try it out during the weekend (don't have card reader anymore and need to create virtual one) but I'm not aware that there would be some special way to build it. Might be that devel is not entirely working so you could try to build master while taking only winscard32/64.def from devel to see if it will help you

@ShiZNizZLe
Copy link
Author

And would that help to get rid of the errors that i first encountered when i tried to build the master?

These:
https://user-images.githubusercontent.com/15122459/109943790-d8ac9780-7cd5-11eb-9641-af9d3af0988e.png

@Arcidev
Copy link
Collaborator
Arcidev commented Mar 10, 2021

If you'll keep the .def files then yes as there are defined methods that have been removed in 2019 by MS in their dll

@ShiZNizZLe
Copy link
Author

just build again:

  • copied the def files from the devel over to the master
  • opened the solution with vs2019
  • built the solution with win32 debug

After that:

  • copied the winscard.dll
  • started the program
  • fails to log properly again

Checked again with the pre compiled 2.1.2 dll, logs properly

I don't know whats going wrong

@ShiZNizZLe
Copy link
Author

i tried to build on windows 2019 server with vs2019 (with the devel def files)
also tried on windows server 2008 r2 (without devel def files, because if i'm correct the methods have not been removed there?)
and after that again but this time WITH the def files.
All result to this:

winscard_rules_log.txt_Thu-Mar-11-11_26_56-2021.txt

@ShiZNizZLe
Copy link
Author

any update?

@ShiZNizZLe
Copy link
Author
ShiZNizZLe commented Mar 16, 2021

Since you mentioned that you were able to build and use the winscard.dll, can you build one for us? I'll give you our modifications right here and also a screenshot so you know where it is exactly:

afbeelding

static SCard LONG(STDCALL *Original_SCardGetAttrib)(
	IN SCARDHANDLE hCard,
	IN DWORD dwAttrId,
	OUT LPBYTE pbAttr,
	IN OUT LPDWORD pcbAttrLen
	);

SCard LONG STDCALL SCardGetAttrib(
	IN SCARDHANDLE hCard,
	IN DWORD dwAttrId,
	OUT LPBYTE pbAttr,
	IN OUT LPDWORD pcbAttrLen
) {
	string_type message;
	message = string_format(_CONV("SCardGetAttrib(hCard:0x%x, dwAttrId:0x%x) called\n"), hCard, dwAttrId);
	LogWinscardRules(message);
	if (theApp.IsRemoteCard(hCard)) {
			LogWinscardRules(_CONV("WARNING: No implementation for remote cards, now just returns with SCARD_S_SUCCESS\n"));
			//https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetattrib
		return SCARD_S_SUCCESS;
	}
	else {
		LONG status = (*Original_SCardGetAttrib)(hCard, dwAttrId, pbAttr, pcbAttrLen);
		LogWinscardRules(string_format(_CONV("SCardGetAttrib returned with the following parameters:(hCard:0x%x,dwAttrId:%ld,pbAttr:%s,pcbAttrLen:%d,returnvalue:%l)\n"), hCard, dwAttrId, LPCSTR(pbAttr), pcbAttrLen, status));
		return status;
	}
}

@ShiZNizZLe
Copy link
Author

never mind, we've built the dll with the 2.1.2 source code, that works, even with the changes that we've made :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants