Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

  1. #pragma warning(push)
  2. #pragma warning(disable:4201)
  3. // Disable error C4201 in public header
  4. // nonstandard extension used : nameless struct/union
  5. #include <nt.h>
  6. #include <ntrtl.h>
  7. #include <nturtl.h>
  8. #include <windows.h>
  9. #include "cardmod.h"
  10. #pragma warning(pop)
  11. DWORD WINAPI I_CardConvertFileNameToAnsi(
  12. IN PCARD_DATA pCardData,
  13. IN LPWSTR wszUnicodeName,
  14. OUT LPSTR *ppszAnsiName)
  15. {
  16. DWORD dwError = 0;
  17. UNICODE_STRING Unicode;
  18. ANSI_STRING Ansi;
  19. memset(&Unicode, 0, sizeof(Unicode));
  20. memset(&Ansi, 0, sizeof(Ansi));
  21. RtlInitUnicodeString(
  22. &Unicode,
  23. wszUnicodeName);
  24. dwError = RtlUnicodeStringToAnsiString(
  25. &Ansi,
  26. &Unicode,
  27. TRUE);
  28. if (STATUS_SUCCESS != dwError)
  29. {
  30. dwError = RtlNtStatusToDosError(dwError);
  31. goto Ret;
  32. }
  33. *ppszAnsiName = (LPSTR) pCardData->pfnCspAlloc(
  34. (strlen(Ansi.Buffer) + 1) * sizeof(CHAR));
  35. if (NULL == *ppszAnsiName)
  36. {
  37. dwError = ERROR_NOT_ENOUGH_MEMORY;
  38. goto Ret;
  39. }
  40. strcpy(*ppszAnsiName, Ansi.Buffer);
  41. Ret:
  42. if (Ansi.Buffer)
  43. RtlFreeAnsiString(&Ansi);
  44. return dwError;
  45. }