2 * PROJECT: ReactOS Local Spooler API Tests Injected DLL
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * PURPOSE: Main functions
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
13 #define WIN32_NO_STATUS
22 #include "../localspl_apitest.h"
28 extern void func_fpEnumPrinters(void);
30 const struct test winetest_testlist
[] =
32 { "fpEnumPrinters", func_fpEnumPrinters
},
38 GetLocalsplFuncs(LPPRINTPROVIDOR pp
)
41 PInitializePrintProvidor pfnInitializePrintProvidor
;
43 // Get us a handle to the loaded localspl.dll.
44 hLocalspl
= GetModuleHandleW(L
"localspl");
47 skip("GetModuleHandleW failed with error %u!\n", GetLastError());
51 // Get a pointer to its InitializePrintProvidor function.
52 pfnInitializePrintProvidor
= (PInitializePrintProvidor
)GetProcAddress(hLocalspl
, "InitializePrintProvidor");
53 if (!pfnInitializePrintProvidor
)
55 skip("GetProcAddress failed with error %u!\n", GetLastError());
59 // Get localspl's function pointers.
60 if (!pfnInitializePrintProvidor(pp
, sizeof(PRINTPROVIDOR
), NULL
))
62 skip("pfnInitializePrintProvidor failed with error %u!\n", GetLastError());
69 // Running the tests from the injected DLL and redirecting their output to the pipe.
71 DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
79 // We only want to run our test once when the DLL is injected to the process.
80 if (fdwReason
!= DLL_PROCESS_ATTACH
)
83 // Read the test to run from the command pipe.
84 hCommandPipe
= CreateFileW(COMMAND_PIPE_NAME
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
85 if (hCommandPipe
== INVALID_HANDLE_VALUE
)
87 DPRINT("DLL: CreateFileW failed for the command pipe with error %lu!\n", GetLastError());
91 if (!ReadFile(hCommandPipe
, szTestName
, sizeof(szTestName
), &cbRead
, NULL
))
93 DPRINT("DLL: ReadFile failed for the command pipe with error %lu!\n", GetLastError());
97 CloseHandle(hCommandPipe
);
99 // Check if the test name is valid.
100 if (!find_test(szTestName
))
102 DPRINT("DLL: Got invalid test name \"%s\"!\n", szTestName
);
106 // Backup our current stdout and set it to the output pipe.
107 iOldStdout
= _dup(_fileno(stdout
));
108 fpStdout
= _wfreopen(OUTPUT_PIPE_NAME
, L
"w", stdout
);
109 setbuf(stdout
, NULL
);
112 run_test(szTestName
);
114 // Restore stdout to the previous value.
116 _dup2(iOldStdout
, _fileno(stdout
));
118 // Return FALSE so that our DLL is immediately unloaded.