Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cr2test, small test util made for cr2 (doh) to print all clocks to console
- //
- #include "stdafx.h"
- #include <windows.h>
- #include <commctrl.h>
- #include <winreg.h>
- typedef int (__stdcall *MSM_GET_CLK_FREQ_KHZ)(int i);
- char *append_char ( const char *s, const char c , BOOL appendNull)
- {
- size_t len = strlen ( s );
- char *ret;
- if (appendNull)
- ret = new char[len + 2];
- else
- ret = new char[len + 1];
- strcpy ( ret, s );
- ret[len] = c;
- if (appendNull)
- ret[len + 1] = '\0';
- return ret;
- }
- void logger(const char *format, ...)
- {
- // Open file
- FILE *handle;
- handle = fopen("\\cr2test.txt", "ab");
- // Append newline
- char* newformat = append_char(format, '\n', true);
- // Print to console
- va_list ap;
- va_start (ap, format);
- vprintf(newformat, ap);
- va_end (ap);
- // Call vfprintf to write with formatting
- va_start (ap, format);
- vfprintf(handle, newformat, ap);
- va_end (ap);
- // Close up
- fclose(handle);
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- logger("Starting up...");
- HMODULE hDll=LoadLibrary(L"clkregim.dll");
- if (!hDll)
- {
- logger("Failed loading dll...");
- //MessageBox(NULL, error, L"Error", MB_OK);
- return 0;
- }
- MSM_GET_CLK_FREQ_KHZ clk_regime_msm_get_clk_freq_khz = (MSM_GET_CLK_FREQ_KHZ)GetProcAddress(hDll, L"clk_regime_msm_get_clk_freq_khz");
- if (!clk_regime_msm_get_clk_freq_khz)
- {
- logger("Couldn't find the exported method...");
- FreeLibrary(hDll);
- }
- logger("Start reading values...");
- for (int i=0; i<256; i++)
- {
- logger("clk_regime_msm_get_clk_freq_khz(%d) = %d", i, clk_regime_msm_get_clk_freq_khz(i));
- }
- logger("Done...");
- FreeLibrary(hDll);
- return 0;
- }
Add Comment
Please, Sign In to add comment