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-2016 Colin Finck <colin@reactos.org>
13 #define WIN32_NO_STATUS
22 #include "../localspl_apitest.h"
28 extern void func_fpEnumPrinters(void);
29 extern void func_fpGetPrintProcessorDirectory(void);
31 const struct test winetest_testlist
[] =
33 { "fpEnumPrinters", func_fpEnumPrinters
},
34 { "fpGetPrintProcessorDirectory", func_fpGetPrintProcessorDirectory
},
39 GetLocalsplFuncs(LPPRINTPROVIDOR pp
)
42 PInitializePrintProvidor pfnInitializePrintProvidor
;
44 // Get us a handle to the loaded localspl.dll.
45 hLocalspl
= GetModuleHandleW(L
"localspl");
48 skip("GetModuleHandleW failed with error %u!\n", GetLastError());
52 // Get a pointer to its InitializePrintProvidor function.
53 pfnInitializePrintProvidor
= (PInitializePrintProvidor
)GetProcAddress(hLocalspl
, "InitializePrintProvidor");
54 if (!pfnInitializePrintProvidor
)
56 skip("GetProcAddress failed with error %u!\n", GetLastError());
60 // Get localspl's function pointers.
61 if (!pfnInitializePrintProvidor(pp
, sizeof(PRINTPROVIDOR
), NULL
))
63 skip("pfnInitializePrintProvidor failed with error %u!\n", GetLastError());
70 // Running the tests from the injected DLL and redirecting their output to the pipe.
72 DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
80 // We only want to run our test once when the DLL is injected to the process.
81 if (fdwReason
!= DLL_PROCESS_ATTACH
)
84 // Read the test to run from the command pipe.
85 hCommandPipe
= CreateFileW(COMMAND_PIPE_NAME
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
86 if (hCommandPipe
== INVALID_HANDLE_VALUE
)
88 DPRINT("DLL: CreateFileW failed for the command pipe with error %lu!\n", GetLastError());
92 if (!ReadFile(hCommandPipe
, szTestName
, sizeof(szTestName
), &cbRead
, NULL
))
94 DPRINT("DLL: ReadFile failed for the command pipe with error %lu!\n", GetLastError());
98 CloseHandle(hCommandPipe
);
100 // Check if the test name is valid.
101 if (!find_test(szTestName
))
103 DPRINT("DLL: Got invalid test name \"%s\"!\n", szTestName
);
107 // Backup our current stdout and set it to the output pipe.
108 iOldStdout
= _dup(_fileno(stdout
));
109 fpStdout
= _wfreopen(OUTPUT_PIPE_NAME
, L
"w", stdout
);
110 setbuf(stdout
, NULL
);
113 run_test(szTestName
);
115 // Restore stdout to the previous value.
117 _dup2(iOldStdout
, _fileno(stdout
));
119 // Return FALSE so that our DLL is immediately unloaded.