Source code of Windows XP (NT5)
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.

52 lines
971 B

  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <windows.h>
  5. DWORD Size;
  6. LPSTR WriteData = "Hello World\n";
  7. HANDLE ReadHandle, WriteHandle;
  8. VOID
  9. WriterThread(
  10. LPVOID ThreadParameter
  11. )
  12. {
  13. DWORD n;
  14. Sleep(10000);
  15. printf("Writing...\n");
  16. WriteFile(WriteHandle,WriteData,Size, &n, NULL);
  17. assert(n==Size);
  18. printf("Done Writing...\n");
  19. Sleep(10000);
  20. printf("Done Sleeping...\n");
  21. }
  22. int
  23. main(
  24. int argc,
  25. char *argv[],
  26. char *envp[]
  27. )
  28. {
  29. BOOL b;
  30. DWORD n;
  31. LPSTR l;
  32. HANDLE Thread;
  33. DWORD ThreadId;
  34. DebugBreak();
  35. b = CreatePipe(&ReadHandle, &WriteHandle,NULL,0);
  36. assert(b);
  37. Size = strlen(WriteData)+1;
  38. l = LocalAlloc(LMEM_ZEROINIT,Size);
  39. assert(l);
  40. Thread = CreateThread(NULL,0L,WriterThread,(LPVOID)99,0,&ThreadId);
  41. assert(Thread);
  42. printf("Reading\n");
  43. ReadFile(ReadHandle,l,Size, &n, NULL);
  44. assert(n==Size);
  45. printf("Reading Done %s\n",l);
  46. }