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.

75 lines
2.0 KiB

  1. #include "basic.h"
  2. #include "sxspool.h"
  3. #include "stdio.h"
  4. extern "C" int __cdecl wmain(int argc, wchar_t** argv)
  5. {
  6. SXS_STRING_POOL strPool;
  7. NTSTATUS Status;
  8. WCHAR * myStrings[] ={L"111", L"222", L"333", L"444", L"555", L"666"};
  9. DWORD dwStringCounter = 6;
  10. SXS_STRING_POOL_INPUT_DATA strOutput;
  11. //
  12. // test for String Pool
  13. //
  14. // step1: adding strings into string pool
  15. for (DWORD i = 0; i < dwStringCounter; i++)
  16. {
  17. SXS_STRING_POOL_INPUT_DATA strInput;
  18. BOOL fAlreadyExist = FALSE;
  19. DWORD dwIndex;
  20. IF_NOT_NTSTATUS_SUCCESS_EXIT(strInput.NtAssign(myStrings[i], wcslen(myStrings[i])));
  21. IF_NOT_NTSTATUS_SUCCESS_EXIT(strPool.Add(0, strInput, fAlreadyExist, dwIndex));
  22. }
  23. // step2: get out string based on index from stringpool
  24. IF_NOT_NTSTATUS_SUCCESS_EXIT(strOutput.NtResize(20));
  25. printf(" Index \t String\n");
  26. printf("------------------------------");
  27. for ( DWORD i =0 ; i < 32; i++)
  28. {
  29. strOutput.Clean();
  30. IF_NOT_NTSTATUS_SUCCESS_EXIT(strPool.FetchDataFromPool(0, i, strOutput));
  31. printf("%d\t%S\n", i, strOutput.GetCch() == 0 ? L"NoString" : strOutput.GetStr());
  32. }
  33. printf("------------------------------");
  34. /*
  35. //
  36. // Test for GUID pool
  37. //
  38. // {928096A8-734F-4f8e-BA83-A1E8927B4605}
  39. DEFINE_GUID(guid_1,
  40. 0x928096a8, 0x734f, 0x4f8e, 0xba, 0x83, 0xa1, 0xe8, 0x92, 0x7b, 0x46, 0x5);
  41. // {9372D783-12E2-4985-8CDA-A6E75E5CBADD}
  42. DEFINE_GUID(guid_2,
  43. 0x9372d783, 0x12e2, 0x4985, 0x8c, 0xda, 0xa6, 0xe7, 0x5e, 0x5c, 0xba, 0xdd);
  44. // {18139889-8DC9-4fc1-8103-026A902609A2}
  45. DEFINE_GUID(guid_3,
  46. 0x18139889, 0x8dc9, 0x4fc1, 0x81, 0x3, 0x2, 0x6a, 0x90, 0x26, 0x9, 0xa2);
  47. // {4205E06C-C92F-441e-A03C-211E4A1BF476}
  48. DEFINE_GUID(guid_4,
  49. 0x4205e06c, 0xc92f, 0x441e, 0xa0, 0x3c, 0x21, 0x1e, 0x4a, 0x1b, 0xf4, 0x76);
  50. GUID myGuids[4] ={};
  51. */
  52. Exit:
  53. return (Status == STATUS_SUCCESS ? 0 : 1);
  54. }